Is it possible to use Task Scheduler to open a VBS file without a command window?
12,801
Use wscript.exe
to run the script, instead of cscript.exe
Related videos on Youtube
Author by
Matthew Wai
Updated on September 18, 2022Comments
-
Matthew Wai over 1 year
set objShell = createobject("wscript.shell") objShell.Run("""C:\Program Files\Windows Defender\MpCmdRun.exe"" ""-SignatureUpdate""") , 0 <br> Set WshShell = CreateObject("WScript.Shell") WshShell.Run chr(34) & "D:\Balloontip.vbs" & Chr(34), 0 Set WshShell = Nothing
The above is used in a VBS file. When I use Task Scheduler to run it, a command window will appear and then disappear immediately. Is it possible to run it without any command window?
If I use the 'Matthew_Wai' user account, the .vbs file can be run with a momentary window.
But if I use 'SYSTEM' as shown below, the .vbs file cannot be run with no window and error message (nothing happens at all).
(I can change my display language to English if need be.)-
sgmoore over 7 yearsWhy can't you run the vbs script? (Did you try running cscript.exe with your vbs script as an argument?) Also, if you are just wanting to open the txt file in notepad, you can run notepad directly and pass the txt file as the argument.
-
Matthew Wai over 7 yearsTask Scheduler cannot directly run a VBS file. Can you teach me how to use Task Scheduler to run cscript.exe with my vbs script as an argument? Actually, the vbs script is used to run a bat file rather than a txt file.
-
sgmoore over 7 yearsWhen you create a task to start a program, it should ask for the program which is in your system32 folder, (ie normally c:\windows\system32\cscript.exe) and it you ask for arguments and you need to enter the full path name of your script file.
-
Matthew Wai over 7 yearsThanks, it works. But when it runs, a command window will still appear and then disappear immediately. Is it inevitable when Task Scheduler runs a file?
-
-
Ben N over 7 yearsNote that the Hidden checkbox applies to whether the task shows up in the Task Scheduler window when View | Show Hidden Tasks is off.
-
Matthew Wai over 7 yearsActually I have to run a .vbs file rather than a .txt file. I have edited my question. See it again.
-
Matthew Wai over 7 years@ Run5k, I had done as you said, but the file could not be run. I have edited my question. Please see it again.
-
Run5k over 7 yearsBefore you said that it was running, but a window would briefly appear... but now it isn't running at all? If the file couldn't be run, what type of error (if any) are you seeing?
-
Matthew Wai over 7 yearsSorry for the misunderstanding. I have edited my question. Please read it again.
-
Matthew Wai over 7 yearsBingo! That’s what I want. It works perfectly. No command window appears. Thank you very much, w32sh!
-
Ben N over 7 years@MatthewWai For what it's worth, running a VBS script also works for me as long as the default handler for that file type is
wscript
. I'm glad the other answer works for you. -
Matthew Wai over 7 yearsJust out of interest, what is the difference between
wscript.exe
andcscript.exe
? -
Ben N over 7 years@MatthewWai
cscript
is designed to run scripts in a console, whilewscript
is marked as being an application that can create windows. (Relevant SO question.)