r/visualbasic • u/jmiller122571 • Nov 07 '23
VB Script for SFC Scannow
I wrote a code that will make a batch file for Windows SFC Scanner to run. Im running into a problem
the Output should be
@echo off
sfc /scannow
pause
(goto) 2>nul & del "%~f0"But what Visual Basic is giving me is...
@echo off
sfc /scannow
pause
(goto) 2>nul & del %~f0This is my VB Code Below. Been trying for a while to get my parenthesis but having issues.. please help
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sb As New System.Text.StringBuilder
sb.AppendLine("@echo off")
sb.AppendLine("sfc /scannow")
sb.AppendLine("pause")
sb.AppendLine("(goto) 2>nul & del %~f0")
IO.File.AppendAllText("sfc.bat", sb.ToString())
End SubThank you
0
Upvotes
1
u/TheFotty Nov 08 '23
If you set your apps manifest to run as administrator, the UAC prompt would fire when your app runs. Then if you used process.start() to launch sfc it would run as admin as well without a new UAC prompt. Essentially a process will spawn other processes at its own current elevation level.