I resolved the issue by performing these steps:
Create the empty Desktop folders at the below path:
C:\Windows\System32\config\systemprofile\Desktop C:\Windows\SysWOW64\config\systemprofile\Desktop
Make sure user has “log on as batch job” permission.
To enable this please follow below steps:
a) Go to the Start menu.
b) Type secpol.msc. and press Enter.
c) The Local Security Policy manager opens.
d) Go to Security Settings - Local Policies - User Rights Assignment node.
e) Double click Log on as a batch job on the right side.
f) Click Add User or Group.
g) Select the user.
h) Click OK.
Create a file and save it with .cmd extension. The .cmd file should contain below cmd:
cscript.exe “<path to .vbs file>”
In the scheduler, give the path as follows:
• Program/script: filename (.cmd filename)
• Start in(optional): file path (path to .cmd file)
This is because normally it would run the script using the shell handler, which by default is wscript.exe
. When there's no desktop environment (because no-one is logged-in) it would fail and abort script execution (or rather, not run the script in the first place).
To fix this, instead of running the .vbs file directly, change it to run cscript.exe
(the command-line script runtime program) with the script's filename passed as the first argument. Also be sure to ensure you don't have any InputBox
or MessageBox
calls (instead use WScript.Echo
to return messages to the user: wscript
displays message-boxes, but cscript
will write it to the console.
Best Answer
I resolved the above issue by performing below steps :
C:\Windows\System32\config\systemprofile\Desktop C:\Windows\SysWOW64\config\systemprofile\Desktop
To enable this please follow below steps :
a) Go to the Start menu.
b) Type secpol.msc. and press Enter.
c) The Local Security Policy manager opens.
d) Go to Security Settings - Local Policies - User Rights Assignment node.
e) Double click Log on as a batch job on the right side.
f) Click Add User or Group.
g) Select the user.
h) Click OK.
Create a file and save it with .cmd extension. The .cmd file should contain below cmd :
cscript.exe “”
In the scheduler, give the path as follows :
• Program/script: filename (.cmd filename)
• Start in(optional): file path (path to .cmd file)