Results 1 to 14 of 14
  1. #1
    2 Star Lounger Syncopator's Avatar
    Join Date
    Dec 2009
    Location
    U.K.
    Posts
    177
    Thanks
    19
    Thanked 2 Times in 2 Posts

    Command-line help for task scheduler please.

    I tried to follow Fred Langa's advice in order to get Windows 10's Sytem Restore to operate as it should, as described in his latest piece in the latest email from Windows Secrets, and in his item "Exploring Windows' Administrative Tools: Part 4", dated October 11, 2012.

    I know nothing about composing command lines so will someone tell me what I need to enter in task Scheduler.


    Equal rights for equal responsibilities.
    Equal opportunities for equal abilities.

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts
    I'm afraid I can't find anything about System Restore in the last three Windows Secrets newsletters, and I don't have access at present to something from 2012.

    However I will say that using SCHTASKS in a Command Prompt window instead of the Task Scheduler GUI is something I would wish to avoid, since it is very complicated.
    And doesn't cover all the options.
    Code:
    SCHTASKS /Create [/S system [/U username [/P [password]]]]
        [/RU username [/RP password]] /SC schedule [/MO modifier] [/D day]
        [/M months] [/I idletime] /TN taskname /TR taskrun [/ST starttime]
        [/RI interval] [ {/ET endtime | /DU duration} [/K] [/XML xmlfile] [/V1]]
        [/SD startdate] [/ED enddate] [/IT | /NP] [/Z] [/F] [/HRESULT] [/?]
    
    Description:
        Enables an administrator to create scheduled tasks on a local or
        remote system.
    
    Parameter List:
        /S   system        Specifies the remote system to connect to. If omitted
                           the system parameter defaults to the local system.
    
        /U   username      Specifies the user context under which SchTasks.exe 
                           should execute.
    
        /P   [password]    Specifies the password for the given user context.
                           Prompts for input if omitted.
    
        /RU  username      Specifies the "run as" user account (user context)
                           under which the task runs. For the system account,
                           valid values are "", "NT AUTHORITY\SYSTEM"
                           or "SYSTEM".
                           For v2 tasks, "NT AUTHORITY\LOCALSERVICE" and 
                           "NT AUTHORITY\NETWORKSERVICE" are also available as well 
                           as the well known SIDs for all three. 
    
        /RP  [password]    Specifies the password for the "run as" user. 
                           To prompt for the password, the value must be either
                           "*" or none. This password is ignored for the 
                           system account. Must be combined with either /RU or
                           /XML switch.
    
        /SC   schedule     Specifies the schedule frequency.
                           Valid schedule types: MINUTE, HOURLY, DAILY, WEEKLY, 
                           MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT.
    
        /MO   modifier     Refines the schedule type to allow finer control over
                           schedule recurrence. Valid values are listed in the 
                           "Modifiers" section below.
    
        /D    days         Specifies the day of the week to run the task. Valid 
                           values: MON, TUE, WED, THU, FRI, SAT, SUN and for
                           MONTHLY schedules 1 - 31 (days of the month). 
                           Wildcard "*" specifies all days.
    
        /M    months       Specifies month(s) of the year. Defaults to the first 
                           day of the month. Valid values: JAN, FEB, MAR, APR, 
                           MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC. Wildcard "*" 
                           specifies all months.
    
        /I    idletime     Specifies the amount of idle time to wait before 
                           running a scheduled ONIDLE task.
                           Valid range: 1 - 999 minutes.
    
        /TN   taskname     Specifies the string in the form of path\name
                           which uniquely identifies this scheduled task.
    
        /TR   taskrun      Specifies the path and file name of the program to be 
                           run at the scheduled time.
                           Example: C:\windows\system32\calc.exe
    
        /ST   starttime    Specifies the start time to run the task. The time 
                           format is HH:mm (24 hour time) for example, 14:30 for 
                           2:30 PM. Defaults to current time if /ST is not 
                           specified.  This option is required with /SC ONCE.
    
        /RI   interval     Specifies the repetition interval in minutes. This is 
                           not applicable for schedule types: MINUTE, HOURLY,
                           ONSTART, ONLOGON, ONIDLE, ONEVENT.
                           Valid range: 1 - 599940 minutes.
                           If either /ET or /DU is specified, then it defaults to 
                           10 minutes.
    
        /ET   endtime      Specifies the end time to run the task. The time format
                           is HH:mm (24 hour time) for example, 14:50 for 2:50 PM.
                           This is not applicable for schedule types: ONSTART, 
                           ONLOGON, ONIDLE, ONEVENT.
    
        /DU   duration     Specifies the duration to run the task. The time 
                           format is HH:mm. This is not applicable with /ET and
                           for schedule types: ONSTART, ONLOGON, ONIDLE, ONEVENT.
                           For /V1 tasks, if /RI is specified, duration defaults 
                           to 1 hour.
    
        /K                 Terminates the task at the endtime or duration time. 
                           This is not applicable for schedule types: ONSTART, 
                           ONLOGON, ONIDLE, ONEVENT. Either /ET or /DU must be
                           specified.
    
        /SD   startdate    Specifies the first date on which the task runs. The 
                           format is dd/mm/yyyy. Defaults to the current 
                           date. This is not applicable for schedule types: ONCE, 
                           ONSTART, ONLOGON, ONIDLE, ONEVENT.
    
        /ED   enddate      Specifies the last date when the task should run. The 
                           format is dd/mm/yyyy. This is not applicable for 
                           schedule types: ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT.
    
        /EC   ChannelName  Specifies the event channel for OnEvent triggers.
    
        /IT                Enables the task to run interactively only if the /RU 
                           user is currently logged on at the time the job runs.
                           This task runs only if the user is logged in.
    
        /NP                No password is stored.  The task runs non-interactively
                           as the given user.  Only local resources are available.
    
        /Z                 Marks the task for deletion after its final run.
    
        /XML  xmlfile      Creates a task from the task XML specified in a file.
                           Can be combined with /RU and /RP switches, or with /RP 
                           alone, when task XML already contains the principal.
    
        /V1                Creates a task visible to pre-Vista platforms.
                           Not compatible with /XML.
    
        /F                 Forcefully creates the task and suppresses warnings if 
                           the specified task already exists.
    
        /RL   level        Sets the Run Level for the job. Valid values are 
                           LIMITED and HIGHEST. The default is LIMITED.
    
        /DELAY delaytime   Specifies the wait time to delay the running of the 
                           task after the trigger is fired.  The time format is
                           mmmm:ss.  This option is only valid for schedule types
                           ONSTART, ONLOGON, ONEVENT.
    
        /HRESULT           For better diagnosability, the process exit code
                           will be in the HRESULT format.
    
        /?                 Displays this help message.
    
    Modifiers: Valid values for the /MO switch per schedule type:
        MINUTE:  1 - 1439 minutes.
        HOURLY:  1 - 23 hours.
        DAILY:   1 - 365 days.
        WEEKLY:  weeks 1 - 52.
        ONCE:    No modifiers.
        ONSTART: No modifiers.
        ONLOGON: No modifiers.
        ONIDLE:  No modifiers.
        MONTHLY: 1 - 12, or 
                 FIRST, SECOND, THIRD, FOURTH, LAST, LASTDAY.
    
        ONEVENT:  XPath event query string.
    Examples:
        ==> Creates a scheduled task "doc" on the remote machine "ABC"
            which runs notepad.exe every hour under user "runasuser". 
    
            SCHTASKS /Create /S ABC /U user /P password /RU runasuser
                     /RP runaspassword /SC HOURLY /TN doc /TR notepad 
    
        ==> Creates a scheduled task "accountant" on the remote machine 
            "ABC" to run calc.exe every five minutes from the specified
            start time to end time between the start date and end date.
    
            SCHTASKS /Create /S ABC /U domain\user /P password /SC MINUTE
                     /MO 5 /TN accountant /TR calc.exe /ST 12:00 /ET 14:00
                     /SD 06/06/2006 /ED 06/06/2006 /RU runasuser /RP userpassword
    
        ==> Creates a scheduled task "gametime" to run freecell on the 
            first Sunday of every month.
    
            SCHTASKS /Create /SC MONTHLY /MO first /D SUN /TN gametime 
                     /TR c:\windows\system32\freecell
    
        ==> Creates a scheduled task "report" on remote machine "ABC"
            to run notepad.exe every week.
    
            SCHTASKS /Create /S ABC /U user /P password /RU runasuser
                     /RP runaspassword /SC WEEKLY /TN report /TR notepad.exe
    
        ==> Creates a scheduled task "logtracker" on remote machine "ABC"
            to run notepad.exe every five minutes starting from the
            specified start time with no end time. The /RP password will be
            prompted for.
    
            SCHTASKS /Create /S ABC /U domain\user /P password /SC MINUTE
                     /MO 5 /TN logtracker 
                     /TR c:\windows\system32\notepad.exe /ST 18:30
                     /RU runasuser /RP
    
        ==> Creates a scheduled task "gaming" to run freecell.exe starting
            at 12:00 and automatically terminating at 14:00 hours every day
    
            SCHTASKS /Create /SC DAILY /TN gaming /TR c:\freecell /ST 12:00
                     /ET 14:00 /K
        ==> Creates a scheduled task "EventLog" to run wevtvwr.msc starting
            whenever event 101 is published in the System channel
    
            SCHTASKS /Create /TN EventLog /TR wevtvwr.msc /SC ONEVENT
                     /EC System /MO *[System/EventID=101] 
        ==> Spaces in file paths can be used by using two sets of quotes, one
            set for CMD.EXE and one for SchTasks.exe.  The outer quotes for CMD
            need to be double quotes; the inner quotes can be single quotes or
            escaped double quotes:
            SCHTASKS /Create 
               /tr "'c:\program files\internet explorer\iexplorer.exe' 
               \"c:\log data\today.xml\"" ...
    BATcher

    Time prevents everything happening all at once...

  3. #3
    2 Star Lounger Syncopator's Avatar
    Join Date
    Dec 2009
    Location
    U.K.
    Posts
    177
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by BATcher View Post
    I'm afraid I can't find anything about System Restore in the last three Windows Secrets newsletters, and I don't have access at present to something from 2012.
    Thank you Batcher. There's a link (Top Story) in the current Newsletter.

    link.jpg

    I'm afraid the rest of your post doesn't help.
    Equal rights for equal responsibilities.
    Equal opportunities for equal abilities.

  4. #4
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts
    My suggestion would be to look at How-To Geek's article "Change How Often System Restore Creates Restore Points in Windows 7 or Vista", which I am assuming is what you want to accomplish. There may be minor differences for Windows 10.
    BATcher

    Time prevents everything happening all at once...

  5. #5
    3 Star Lounger djohnson's Avatar
    Join Date
    Dec 2009
    Location
    Delaware City, Delaware
    Posts
    323
    Thanks
    13
    Thanked 32 Times in 30 Posts
    Here is how to run with Task Scheduler, a restore point at login every time without fail. You need to follow these instructions exactly or else it will not work.
    1) On your C drive create a folder called Customizations
    2) In the Customizations folder create another folder called RestorePoint. At this time you will have C:\Customizations\RestorePoint
    3) Open notepad, and paste in
    Code:
    wmic.exe /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "Automatic Restore Point", 100, 7
    4) In the top right hand corner, click on File -> Save As. Paste in "CreateRestorePoint.cmd" with the quotation marks, and save to the C:\Customizations\RestorePoint location.
    5) Once again open notepad, and paste in
    Code:
    Dim WinScriptHost
    Set WinScriptHost = CreateObject("WScript.Shell")
    WinScriptHost.Run Chr(34) & "C:\Customizations\RestorePoint\CreateRestorePoint.cmd" & Chr(34), 0
    Set WinScriptHost = Nothing
    6) In the top right hand corner, click on File -> Save As. Paste in "CreateRestorePoint.vbs" with the quotation marks, and save to the C:\Customizations\RestorePoint location.
    7) Open notepad for the last time, and paste in
    Code:
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
      <URI>\Restore Point at Startup</URI>
      </RegistrationInfo>
      <Triggers>
        <LogonTrigger>
          <Enabled>true</Enabled>
        </LogonTrigger>
      </Triggers>
      <Principals>
        <Principal id="Author">
          <GroupId>S-1-5-32-545</GroupId>
          <RunLevel>HighestAvailable</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>false</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <IdleSettings>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
        <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
        <WakeToRun>false</WakeToRun>
        <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
        <Priority>3</Priority>
      </Settings>
      <Actions Context="Author">
        <Exec>
          <Command>CreateRestorePoint.vbs</Command>
          <WorkingDirectory>C:\Customizations\RestorePoint\</WorkingDirectory>
        </Exec>
      </Actions>
    </Task>
    8) In the top right hand corner, click on File -> Save As. Paste in "RestorePointStartup.xml" with the quotation marks, and save to the C:\Customizations\RestorePoint location.
    9) Now we are almost done. Open Task Scheduler. You can click on the start button, and type Task Scheduler. It will appear at the top of your Start Menu before you are done.
    10) Select Import Task, browse to the C:\Customizations\RestorePoint folder, and you will see RestorePointStartup.xml. Double-click on it, then click OK.
    11) Done! Now just log off, then back on. When you check your restore points you will find the one just created.
    Last edited by djohnson; 2016-10-19 at 11:56.

  6. #6
    2 Star Lounger Syncopator's Avatar
    Join Date
    Dec 2009
    Location
    U.K.
    Posts
    177
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by BATcher View Post
    My suggestion would be to look at How-To Geek's article "Change How Often System Restore Creates Restore Points in Windows 7 or Vista", which I am assuming is what you want to accomplish. There may be minor differences for Windows 10.
    Thank you BATcher.
    Windows 10 shows me different windows, so the Win 7 instructions won't work.


    I have just seen djohnson's suggestion. I shall try that.
    Equal rights for equal responsibilities.
    Equal opportunities for equal abilities.

  7. #7
    2 Star Lounger Syncopator's Avatar
    Join Date
    Dec 2009
    Location
    U.K.
    Posts
    177
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Thank you djohnson

    I have tried that twice, being very careful to copy the instructions exactly.

    Both times, when I paste the xml file into the RecoveryPoint folder, I get this messge:

    warning.jpg

    Then, when I double click on the file, it opens up Dreamweaver which then displays the xml code.

    I rebooted after both tries but no restore point was created.

    What am I missing?
    Equal rights for equal responsibilities.
    Equal opportunities for equal abilities.

  8. #8
    3 Star Lounger djohnson's Avatar
    Join Date
    Dec 2009
    Location
    Delaware City, Delaware
    Posts
    323
    Thanks
    13
    Thanked 32 Times in 30 Posts
    You did not follow the directions. Just click OK with the unicode format. BUT DO NOT CLICK ON THE FILE TO OPEN IT. I DID NOT SAY THAT. You open task scheduler, and import the xml file using the import function in task scheduler. See steps 9, 10, and 11.


    Last edited by djohnson; 2016-10-19 at 15:53.

  9. The Following User Says Thank You to djohnson For This Useful Post:

    Syncopator (2016-10-19)

  10. #9
    2 Star Lounger Syncopator's Avatar
    Join Date
    Dec 2009
    Location
    U.K.
    Posts
    177
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Ok, thank you. That's fixed it.
    Equal rights for equal responsibilities.
    Equal opportunities for equal abilities.

  11. The Following User Says Thank You to Syncopator For This Useful Post:

    djohnson (2016-10-19)

  12. #10
    2 Star Lounger Syncopator's Avatar
    Join Date
    Dec 2009
    Location
    U.K.
    Posts
    177
    Thanks
    19
    Thanked 2 Times in 2 Posts
    It was working fine until a recent upgrade/s. Now it doesn't work. I have deleted the folders and started again. It still doesn't work.

    Can you suggest a remedy?
    Equal rights for equal responsibilities.
    Equal opportunities for equal abilities.

  13. #11
    3 Star Lounger djohnson's Avatar
    Join Date
    Dec 2009
    Location
    Delaware City, Delaware
    Posts
    323
    Thanks
    13
    Thanked 32 Times in 30 Posts
    Make sure you have system restore enabled. Also, open Task Scheduler, highlight the task, and click on run. Check your restore points. Then restart, and recheck.

  14. The Following User Says Thank You to djohnson For This Useful Post:

    Syncopator (2016-11-06)

  15. #12
    2 Star Lounger Syncopator's Avatar
    Join Date
    Dec 2009
    Location
    U.K.
    Posts
    177
    Thanks
    19
    Thanked 2 Times in 2 Posts

    ANSI encoding

    I have done all that, but is still doesn't work.

    When I go to save the xml file I am warned that it might not work if saved with ANSI encoding. I have saved with both ANSI and Unicode, but neither works.
    Equal rights for equal responsibilities.
    Equal opportunities for equal abilities.

  16. #13
    3 Star Lounger djohnson's Avatar
    Join Date
    Dec 2009
    Location
    Delaware City, Delaware
    Posts
    323
    Thanks
    13
    Thanked 32 Times in 30 Posts
    Quote Originally Posted by Syncopator View Post
    I have done all that, but is still doesn't work.

    When I go to save the xml file I am warned that it might not work if saved with ANSI encoding. I have saved with both ANSI and Unicode, but neither works.
    You do know you must actually import it into task scheduler. Don't you have it from the first time? When asked just click OK, and save. Whatever it wants to do is alright. There really shouldn't be an issue surrounding this, just accept the default. Import into task scheduler. You really need to follow the directions I have posted EXACTLY as I posted them. No assumptions please.

  17. #14
    2 Star Lounger Syncopator's Avatar
    Join Date
    Dec 2009
    Location
    U.K.
    Posts
    177
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by djohnson View Post
    You do know you must actually import it into task scheduler.
    Yes, of course, and I did import it.

    Don't you have it from the first time?
    No, I have reinstalled the operating system since then.

    When asked just click OK, and save. Whatever it wants to do is alright. Import into task scheduler.
    It has been imported into Task Scheduler.

    You really need to follow the directions I have posted EXACTLY as I posted them. No assumptions please.
    I'm quite sure that I am.
    Equal rights for equal responsibilities.
    Equal opportunities for equal abilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •