Cannot create run-once task with schtasks

G

Graeme Perrow

I am trying to create a task that runs once and then gets deleted. According
to (my interpretation of) the schtasks /? information, this should work:

schtasks /create /sc once /tn OneSync /tr C:\bat\sync.bat /st 10:58 /F /Z

This should run c:\bat\sync.bat at 10:58am today (assuming it's before
10:58am now), and then delete the task (/Z). However, I get this message:

ERROR: The task XML is missing a required element or attribute.

If I take the /Z away, the task is created as expected and runs at the right
time, but does not get deleted afterwards.

I am running (64-bit) Vista. Is this a bug, or am I missing something? If I
do the same thing on XP (without /F and /Z) the task is created, runs at the
right time, and then vanishes, which is exactly what I want.
 
J

Jon

Using the /V1 switch seemed to work here - notepad ran and then the task was
deleted- although I had to enter the password manually in this case. You
may be able to tweak it further.

schtasks /create /sc once /tn Notepad /tr C:\Windows\System32\notepad.exe
/st 19:02 /F /Z /V1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top