Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Schedule ONE-TIME task with "schtasks" at next reboot?

10 Mar 2015   #1

win7pro 64bit
Schedule ONE-TIME task with "schtasks" at next reboot?

As you know users can setup a task to be run at startup with the built-in task scheduler "schtasks" with

schtasks /sc ONSTART ... /TR ...

However this command syntax triggers the task at EVERY BOOT time.
How do I setup (from command line and not through GUI!!!) a ONE-TIME task?

For simplicity lets assume I want to run chkdsk for partition E: ONCE at next reboot.

How can I achieve this with "schtasks" built-in command?

I don't want to specify a certain time because it varies from time to time and computer to computer and exacty boot time cannot be specified.


My System SpecsSystem Spec
10 Mar 2015   #2

Windows 7 Ultimate x64

Not tried it, but quickly seeing the help I can think of two ways for that.

/Z modifier says that it marks the task for deletion after the next execution (not completely sure, but it might work for auto-deleting it after running).
Another option could be to modify the program pointed to /TR to a bat file instead. It will first run the original program and then invoke schtasks again to delete the task, effectively running it only once.

Other possibilities without involving the task scheduler could be to use the registry key specifically designed for this. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce and HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce can point to any programs that are run at login of either every user or a particular one, but then autodeleted by the system itself without further intervention required (installers sometimes drop cleanup routines to perform after reboot.
Note that the registry option is not executed at system startup, but at user login instead.
My System SpecsSystem Spec

 Schedule ONE-TIME task with "schtasks" at next reboot?

Thread Tools

Similar help and support threads
Thread Forum
"Activation was successful" comes up every time I REBOOT
I have windows 7 Ultimate with all updates. Every time I re-boot it, a window comes up saying "Activation was successful" On the Computer properties screen it says Window are activated and genuine. Diagnostic Report (1.9.0019.0): ----------------------------------------- WGA Data-->...
Windows Updates & Activation
"reboot and select proper boot device" on every reboot
This is my first ever post here on this forum so sorry if my info is less than you need. So the problem is that every time i reboot my computer i get "reboot and select proper boot device. Or insert boot media in selected boot device and press a key" on the screen. I have been in the bios and...
General Discussion
W7 64bits Task Scheduler, the selected task "{0}" no longer exists
Hi, So I don't know when this: "the selected task "{0}" no longer exists. to see the current task, click refresh" error started but I don't know how to repair this. When I start task scheduler I first get this error and than no matter what folder I click the error pops up again. After this 2nd...
General Discussion
the task bar "folder" pinned "program"
I usually use it by pinning my frequently use folder, so when I right click, the list of "pinned program (folder)" will be listed out, easy for me to access them in a click. and one day, all the pinned programs gone. so I attempted to "repin" all vanish folders, but even if I click to pin...
General Discussion
Install time difference between "Upgrade" and "Custom"
Is the time to "Upgrade from vista to 7 supposed to be wayyy longer then it would to do jsut a clean install? (For example, hanging at 18% for a while while installing during upgrade) (posting this since i cant get any replies to a previous topic)
Installation & Setup

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:19.
Twitter Facebook Google+