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!

Was it helpful?

Solution

Adding "cmd /c" to the front of the command

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c SCHTASKS /QUERY > winning.txt"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top