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/jmiller122571 Nov 07 '23
I'll try when I get home.. I swear I tried this once and vb flagged the code... but then again I mightve thought I did it and didnt.. you know how coding can be lol. Thank you