vbscriptscheduled-tasksscheduler

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


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.


Solution

  • 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)