Adding "cmd /c" to the front of the command
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c SCHTASKS /QUERY > winning.txt"
Question
Here is the code that I have currently:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "SCHTASKS /QUERY > winning.txt"
In my head this should work correctly, and it runs without errors, but the text file is not updated.
The text file is already created so I do not have to worry about creating the WScript variable
EDIT:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c SCHTASKS /QUERY > winning.txt"
Thank you David! I was looking at those two lines for hours!
Solution
Adding "cmd /c" to the front of the command
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c SCHTASKS /QUERY > winning.txt"