how to cancel a scheduled command for CMD

1

i just scheduled a hibernate command:

at 13:00 shutdown /h

Is there any command to abort this scheduled operation?

  1. shutdown /a didn't work, it said there is no scheduled shutdown.

  2. At 12:59 shutdown /a didn't work as well for aborting At 13:00 shutdown /h

Ashu Kumar

Posted 2016-04-16T14:04:12.697

Reputation: 11

Type schtasks /? and take it from there. – AFH – 2016-04-16T14:32:12.823

@afh at {id} /delete is much simpler ;) – DavidPostill – 2016-04-16T14:33:05.350

@DavidPostill - OK. Win10 tells me that at is deprecated and to use schtasks instead. – AFH – 2016-04-16T14:35:35.840

@AFH Yes "The AT command has been deprecated and is no longer available In Windows 8." so the OP must have Windows 7 or earlier ;) – DavidPostill – 2016-04-16T14:38:08.313

@AFH And if you want delete with schtasks you have to know the taskname create from the at command, which will be At{id} ... – DavidPostill – 2016-04-16T14:43:50.767

@DavidPostill - I have upgraded all my W7/8 systems to W10, so I have no means of checking. My only remaining Windows systems are XP and Vista somewhere on a Linux laptop. Thanks for the cmd reference in your answer: I have used a separate search each time I need more information than /? gives: now I have a direct reference. – AFH – 2016-04-16T15:00:41.740

Answers

0

Is there any command to abort this scheduled operation?

at 13:00 shutdown /h

You can run at by itself to list the scheduled jobs. Example:

F:\test>at 13:00 echo "hello"
Added a new job with job ID = 1

F:\test>at
Status ID   Day                     Time          Command Line
---------------------------------------------------------------------
        1   Tomorrow                13:00         echo hello

This returns a list of scheduled jobs, together with an ID for each job.

To delete a scheduled job:

at ID /delete

Example:

F:\test>at 13:00 echo "hello"
Added a new job with job ID = 1

F:\test>at
Status ID   Day                     Time          Command Line
-------------------------------------------------------------------------------
        1   Tomorrow                13:00         echo hello

F:\test>at 1 /delete

F:\test>at
There are no entries in the list.

To delete a scheduled job using schtasks:

schtasks /delete /tn At{ID}

Where {ID} is the ID of the at task.

Example:

F:\test>schtasks /delete /tn At1
WARNING: Are you sure you want to remove the task "At1" (Y/N)? y
SUCCESS: The scheduled task "At1" was successfully deleted. 

To delete all scheduled jobs:

at /delete /yes

at usage

F:\test>at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       Allows the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is assumed.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next Thursday).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.

Further Reading

DavidPostill

Posted 2016-04-16T14:04:12.697

Reputation: 118 938

0

Shutdown /a will only work after the shutdown has been schedule using the command

So wait for the shutdown event to trigger and then run shutdown /a

so if you run this at 13.01 it would work

SeanClt

Posted 2016-04-16T14:04:12.697

Reputation: 1 960

at {id} /delete is much simpler ;) – DavidPostill – 2016-04-16T14:33:56.560

It's a matter of choice I have backup scheduled daily at 5pm on my servers and then I shutdown using this command but if I am still working I just use shutdown /a to cancel it – SeanClt – 2016-04-16T14:35:37.180