none
Create a Scheduled task that uses the local admin account RRS feed

  • Question

  • Hi Mr.Bosses.  

    My question is the command line Schtasks.exe. I want to create a task with local administrators member and run the task under domain user logged on. And run only ONCE.

    Example:

    I was logged on with user Domainuser on windows 7 platform.

    C:\Windows>schtasks /create /tn "Reg" /tr "regedit.exe" /sc once /st 23:55 /ru Administrator /rp Password /RL Highest 

    Then I got this:

    SUCCESS: The scheduled task "Reg" has successfully been created. 

    Then 

    C:Windows>schtasks /run /i /tn Reg (This place could use /u Username /p password option but I dont know why should use it.)

    INFO: scheduled task "Reg" is currently running. 

    SUCCESS: Attempted to run the scheduled task "Reg". 

    Seemed okay But the task was actually not run without any log or error message. This task Only run under domain user's permission, just like this. 

    C:Windows>schtasks /create /tn "Reg" /tr "regedit.exe" /sc once /st 23:55 /ru DomainUser /rp Password /RL Highest 

    SUCCESS: The scheduled task "Reg" has successfully been created.

    And right here I have to open Task Scheduler GUI and change the option "Run whether user is logged or not " to "Run only when user is logged on" then the regedit.exe will be running. 

    C:Windows>schtasks /run /i /tn Reg 

    INFO: scheduled task "Reg" is currently running. 

    SUCCESS: Attempted to run the scheduled task "Reg". (Now the regedit.exe popped up.)

    So the first thing is how to create the task with local admin permission and run it under domain user logged on. The second thing is how to create the task with default option "Run only when user is logged on". (By the way I think "Run whether user is logged or not " option is suitable but it doesn't work.) 

    Sorry for the bad english and thanks for help.

    Tuesday, June 20, 2017 8:03 AM

All replies

  • Hi,

    Based on your description, it seems that there is something wrong with task scheduler, we can try troubleshooting tools and check if it helps.

    Troubleshooting Task Scheduler

    https://technet.microsoft.com/en-us/library/cc721846(v=ws.11).aspx

    In addition, we can also try to assign computer startup scripts.

    Assign Computer Startup Scripts

    https://technet.microsoft.com/en-us/library/cc770556%28v=ws.11%29.aspx?f=255&MSPPError=-2147217396

    Best Regards,

    Tao


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

    Wednesday, June 21, 2017 3:55 AM
    Moderator
  • ...

    Thank you  Tony_Taoand sorry for the delayed reply.

    I've read the threads you recommended and that's not the right solution for my question.

    Both of that threads are talking about Task Scheduler GUI and my problem is with Task Scheduler command (Schtasks.exe). And my Task Scheduler GUI works fine.

    And I don't really understand what does the startup script related to the shatasks question. (The task only for specified users)

    Thanks again and expecting the solution.

    Monday, July 10, 2017 3:03 AM