locked
Task scheduler start a task and shows running, but nothing happens. RRS feed

  • Question

  • I am here to setup task scheduler in a Windows 2008 R2,x64 server

    I am logon as local administrator and created the job to run as local administrator as well.

    my schedule job is as simple as open a notepad, and the task scheduler shows my job is running with 0x41301 result.

    the notepad never pop up, but I check the task manager, shows the notepad is there, and process held by an administrator.

    My script is a .bat format.

    @echo off

    echo %date% %time% %username% >>c:\temp\test.txt

    echo running "notepad" >> c:\temp\test.txt

    notepad

    echo end %date% %time% >> c:\temp\test.txt

    And the output result from test.txt

    Tue 10/25/2016 16:19:50:67 Administrator

    Running notepad

    result ends here.

    and notepad not pop up

    Tuesday, October 25, 2016 8:38 AM

Answers

  • Hi Dave:

    Its definitely not the script. because if i manually double click the script to run, it run all well.

    but when let the scheduler run the script, it stays in the process bar, and hangs there.

    Regards

    Focusmind

    Something about your script is problematic when there is no desktop environment loaded. You may need to involve someone familiar with your java process for help.

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Thursday, November 3, 2016 2:40 PM

All replies

  • You may need to select "run only when user logged on"

    Also uncheck "hidden"

     

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Tuesday, October 25, 2016 9:33 PM
  • Hi Dave:

    I played around the two switches, if set " run only when user logged on", the job pops and my program run as it suppose to.

    How do I configure the job to run if I set "run wether user is logged or not"? it seems my program held in the process at the background, but the program never executing. just hangs there.

    the rest of the task scheduler settings is default, and "Hidden" is unchecked.

    Thanks

    Kin

    Wednesday, October 26, 2016 2:37 AM
  • Not sure what the point is but task scheduler is not really a tool for presenting visual results. Possibly create two tasks. One runs in background and another runs when logged on.

     

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.


    Wednesday, October 26, 2016 2:41 AM
  • Hi Focusmind,

    >> and notepad not pop up

    Please check if other applications take up lot of memory usage or disk read usage.

    You could end the process on task manager, and manually open the notepad again, and check if it pops up.

    Please check if txt file was authorized for notepad opening.

    Best Regards

    John


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, October 26, 2016 3:10 AM
  • Hi Dave:

    Notepad is just a sample of scheduler testing, just to see where scheduler stuck at. I dont really need a visual result, but I require it to run and execute the jobs instead of hangs there in the background, and nothing happens.

    For real schedule, I am running ONE vbs script that will execute many sections of java codes, whereheader code define variables, it will have body and bottom java codes to calculate the data and output results.

    now the behavour is the header coding run by scheduler, hang up right before the second code calls to run.
    imagine header code getting variables and then body code read variables to make calculations.
    I cannot create two seperate script for scheduler to run.

    If I double click the vbs script, or the bat script. it all runs well. But once I use scheduler to run the script, a wscript.exe process stay at the background and nothing happens.

    Wednesday, October 26, 2016 6:26 AM
  • Hi John;

    it is a clean installed Windows 2008R2, nothing busy on it.

    I kill the process and rerun the scheduler, what happened is job stay in process, but nothing got executed.

    txt file is simply to output the running result from sheduler, and I am logging/running with administrator.

    Wednesday, October 26, 2016 6:30 AM
  • It sounds like the issue may be in the code not task scheduler. You can get more details of task events by checking;

    Event Viewer\Applications\Microsoft\Windows\TaskScheduler\Operational

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Wednesday, October 26, 2016 12:39 PM
  • Hi Dave:

    Its definitely not the script. because if i manually double click the script to run, it run all well.

    but when let the scheduler run the script, it stays in the process bar, and hangs there.

    Regards

    Focusmind

    Thursday, November 3, 2016 9:58 AM
  • you need to check the event log for more details.

    Regards,
    Sandeep Poonia
    Please verify the answer if it helps you.

    Thursday, November 3, 2016 10:05 AM
  • Hi Dave:

    Its definitely not the script. because if i manually double click the script to run, it run all well.

    but when let the scheduler run the script, it stays in the process bar, and hangs there.

    Regards

    Focusmind

    Something about your script is problematic when there is no desktop environment loaded. You may need to involve someone familiar with your java process for help.

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Thursday, November 3, 2016 2:40 PM
  • Probably way too late to be helpful to the original poster, but in case it helps others... I had the exact same problem in every way. Even the same result code. 

    Defining a "Start In" path on the Task's Action resolved the issue.

    Thursday, January 18, 2018 8:55 PM
  • I have the same problem running a one line batch script-

    It will execute once an keep running.

    Unfortunately the "start in" path fix doesn't work for me.

    I changed the Settings > If the task is already ..... to "Stop the existing instance"

    The task still says "Running" but when the next task runs it works.

    Wednesday, August 8, 2018 3:08 AM
  • I have the same problem running a one line batch script-

    It will execute once an keep running.

    Unfortunately the "start in" path fix doesn't work for me.

    I changed the Settings > If the task is already ..... to "Stop the existing instance"

    The task still says "Running" but when the next task runs it works.

    I'd start a new thread.

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Wednesday, August 8, 2018 3:10 AM
  • Yes, that did it for me as well.  My job only runs properly with "run only when user logged on."  But why doesn't the job run with "run whether user is logged or not?"  And when would you use that setting?

    Thanks

    Friday, March 22, 2019 3:15 PM
  • I know this is a late post but this is my understanding.  You are testing with a script that opens Notepad but your real script has no user interaction.

    If you specify Run whether user is logged on or not (which you want to do) - if you test with your real script that does not interact with the user I think you'll find it works.

    Your test script opens Notepad.  Your test script (if you check Task Manager) I'll bet is executing.  It has displayed an open Notepad window and is waiting for user input just as you'd expect so the script is waiting for human input.

    The only thing special is that you are thinking "if I'm logged on I should see the Notepad" but this is wrong.  You told Windows "run this script and ignore if I'm there" so the Notepad window is opening but NOT on your interactive user's screen.  It is running under your userid but NOT something you can see on your terminal.  If you want that, uncheck Run whether user .......

    Pretty sure this is the issue.  Also note another issue some run into - if you check Run with highest privilege and the user has Admin auth, that task will run with the Admin security token which is NOT the token that has access to Network drives (by default) so if you map a network drive in your script it is mapped to your non admin token so when your script runs it won't have access so either run the ask w/o highest privilege (does the script REALLY require Admin?) or there is a global registry change that changes Windows behaviour to allow your Admin security token to see your non admin mapped network drives.

    Hope I'm right on what the problem is and sorry for the late post.  Better late than never.

    Thursday, September 5, 2019 1:52 AM
  • Thank you Gary - I had exactly the same problem, and your solution worked.

    Thank you also for taking the time to explain how "logged in" vs "Not logged in" works...that was indeed the piece of the puzzle that I missed!

    Thursday, September 26, 2019 10:23 AM