Windows – the command line to schedule a task to be executed once and soon

command linescheduled-taskswindows 7

I know there is the at and schtasks.
But I couldn't figure out how to use them to execute a task soon and once.
I have read about a soon command, but there isn't such command in my Windows version.

I plan to include this command in a batch file and, because of that, I can't hardcode the start time.

Best Answer

The schtasks command can run a defined task immediately.

From How to use Schtasks.exe to Schedule Tasks in Windows Server 2003

Schtasks /Run

Starts a scheduled task immediately. The run operation ignores the schedule, but uses the program file location, user account, and password that are saved in the task to run the task immediately.


schtasks /run /tn TaskName [/s computer [/u [domain\]user /p password]] /?

So just define the task, then run it immediately at any time you need to.

Related Question