Task Scheduler Problem - Run whether user is logged on or not is not working
Asked Answered
I

2

7

I have a batch file which in turn calls VB Script. The task of the VBScript contains a macro whose job is to login into the Oracle db, run few queries, fetch the output in Excel sheet and then it performs other functions.

The script is running fine in the scheduler when using the "Run only when user is logged in" option but it doesn't run when "Run whether user logged in or not" option is selected.

I tried all the options suggested here in previous posts but none of them worked.

Igenia answered 4/2, 2019 at 13:8 Comment(8)
Does the user have the "log on as batch job" privilege? Besides, this question is probably more on-topic on SuperUser than it is on SO.Sufism
Yes the user has "log on as batch job" privilege.Igenia
Related.Sufism
@AnsgarWiechers, it's not working stillIgenia
"It's not working" is not a valid problem description. My previous comment links to an older answer of mine that outlines some troubleshooting steps (mostly for PowerShell, but they should be applicable to VBScript as well). Did you follow them? What were your findings? Please edit your question to provide additional information.Sufism
Yes i followed them, the job doesn't run at all.Igenia
@AnsgarWiechersIgenia
@AnsgarWiechers, i have given a path for mapped server in my macro, is the issue because of that ?Igenia
I
12

I resolved the above issue by performing below steps :

  1. Create the empty Desktop folders at the below path :

C:\Windows\System32\config\systemprofile\Desktop C:\Windows\SysWOW64\config\systemprofile\Desktop

  1. 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.

  1. Create a file and save it with .cmd extension. The .cmd file should contain below cmd :
    cscript.exe “”

  2. In the scheduler, give the path as follows :
    • Program/script: filename (.cmd filename)
    • Start in(optional): file path (path to .cmd file)

Igenia answered 11/2, 2019 at 7:41 Comment(2)
You are a life saver. Been looking for this forever!Mown
Doesn't work for me :(Insufficiency
T
0

I found out my issue had to do with network drives.

Network drives are not accessible when user is not logged in, so I had to replace with full name (e.g. instead of cd Y: I had to do cd \\server-somewhere.com).

If you are changing the directory to network drive within your script, this is probably the issue.

Easy to check with logging dir results after changing directory:

cd ....
dir | Out-File myLogFile.txt -Append;
Transonic answered 19/8, 2024 at 10:15 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.