1

I want to run my VBS file script in the background on a specific date.

my VBS file is simple (call to the batch file and run it in mode invisible)

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "C:\Temp\Generate_Report.bat" & Chr(34), 0
Set WshShell = Nothing

PS: when I run the VBS file manually it works well but if I want to run it with TASK Scheduler I got this error. enter image description here

Configuration file (VBS in the Task Scheduler tool) enter image description here

MokiNex
  • 857
  • 1
  • 8
  • 21
  • 1
    You will need to show us how you configured the task in Task Scheduler. I hope you are using cscript.exe. Also, this is not a batch-file question. I am removing that tag. – Squashman May 03 '18 at 15:42
  • Done, Please take a look – MokiNex May 03 '18 at 15:45
  • 2
    On the General tab how do you have it configured to run? Also, I gave you a hint in the my previous comment. You should really use `cscript.exe` and pass the vbscript file as an argument. – Squashman May 03 '18 at 15:48
  • or wscript.exe https://superuser.com/questions/1149959/is-it-possible-to-use-task-scheduler-to-open-a-vbs-file-without-a-command-window – Slai May 03 '18 at 15:57
  • how to create cscript.exe I'm quite new in this field – MokiNex May 03 '18 at 16:09
  • Cut and paste the value in `Program/script:` to `Add arguments (optional):`. In the `Program/script:` box type `cscript.exe`. However, if all you're doing is running the .bat file, you can just put that in the `Program/script:` box. – langstrom May 04 '18 at 17:36
  • Thanks Squashman! using cscript.exe and passing the vbs file as an argument worked for me. I still don't know why hitting the vbs script directly works on one of my machines, but not the other. But this way of doing it works great! – NL3294 Oct 22 '19 at 16:20

0 Answers0