Dim Script As String = $"@echo off
echo Restarting Notepad
echo Waiting for 5 seconds...
timeout /t 5 /nobreak > NUL
echo Starting the application...
start "C:\WINDOWS\system32\notepad.exe"
exit
"$
Dim BatchFile As String = File.Combine("C:\", "NotepadRestarter.bat")
File.WriteString(File.GetFileParent(BatchFile), File.GetName(BatchFile), Script)
If File.Exists(File.GetFileParent(BatchFile), File.GetName(BatchFile)) Then
Dim sh As Shell
sh.Initialize("Restart", BatchFile, Null)
sh.Run(1000)
Else
LogError("Restart failed")
End If