Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Creating Scheduled task in Windows 7

  • 16-12-2010 06:52PM
    #1
    Registered Users, Registered Users 2 Posts: 4,325 ✭✭✭


    I am creating a scheduled task from a DOS command that shuts down my PC at 1.00 every day. It adds it to the task scheduler but I want it to run "whether user is logged in or not" but I don't know how to do it in DOS.

    As I say, it is added to task scheduler but the option "Run only when user is logged on" is always ticked. This is what I have so far:

    SCHTASKS /CREATE /SC DAILY /MO 1 /TN ShutdownTask /TR "C:\Windows\System32\shutdown.exe" /ST 13:00:00


    I just need the extra bit that goes into the command above that makes it run whether the user is logged in or not.


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    You'll get the "Run whether user is logged in or not" by including the /S Computername /RU username /RP password, so the scheduler knows the credentials that it's to use when running the program.

    If you just type in /RP, without entering the password within the command line, as below, it'll simply prompt you for the password to use, so that your password is not stored in the command buffer.
    SCHTASKS /CREATE /S mylocalcomputername /RU theusersname /RP /SC DAILY /MO 1 /TN ShutdownTask /TR "C:\Windows\System32\shutdown.exe" /ST 13:00:00

    Try typing
    schtasks /create /?
    into a console to see the other examples.

    If you get the error "Error: Access is denied" then you need to use an elevated command prompt.


  • Registered Users, Registered Users 2 Posts: 4,325 ✭✭✭lukin


    Just adding /ru "System" to the end of it fixed it.

    SCHTASKS /CREATE /SC DAILY /MO 1 /TN ShutdownTask /TR "C:\Windows\System32\shutdown.exe" /ST 13:00:00 /ru "System"


Advertisement