Is it possible to disable a scheduled task from the command line in Windows XP?
Solution 1:
The /disable
switch is only a feature of Vista/7/2008R2/2012.
You can simply rename the task .job
file to "disable" it.
schtasks /Create /SC HOURLY /TN "TEST TASK" /TR notepad
schtasks
TaskName Next Run Time Status
==================================== ======================== ===============
TEST TASK 09:45:00, 7/26/2010
move "C:\WINDOWS\Tasks\TEST TASK.job" "C:\WINDOWS\Tasks\TEST TASK.bak"
schtasks
INFO: There are no scheduled tasks present in the system.
In order to "enable" the task rename the .bak
file to .job
:
schtasks
INFO: There are no scheduled tasks present in the system.
move "C:\WINDOWS\Tasks\TEST TASK.bak" "C:\WINDOWS\Tasks\TEST TASK.job"
schtasks
TaskName Next Run Time Status
==================================== ======================== ===============
TEST TASK 09:45:00, 7/26/2010
Solution 2:
In order to acheive the run-once behaviour, you could always just code a 'wrapper' bat script that checks for a lock file.
Create the lock file on first run, and every there after the wrapper script will just exit if it finds the lock file:
if exist Lock.file goto :eof