Reputation: 2605
I am new to SCHTASKS and cannot get it to run a simple command. What I tried is below. The file c:\downloads\temp_w.txt is not created. What is wrong?
c:\downloads>ver
Microsoft Windows [Version 10.0.17763.503]
c:\downloads>SCHTASKS /Create /SC MINUTE /MO 1 /TN mydir /TR "dir c:\windows > c:\downloads\temp_w.txt"
WARNING: The task name "mydir" already exists. Do you want to replace it (Y/N)? y
y
SUCCESS: The scheduled task "mydir" has successfully been created.
c:\downloads>schtasks /run /tn mydir
SUCCESS: Attempted to run the scheduled task "mydir".
c:\downloads>dir temp_w.txt
Volume in drive C has no label.
Volume Serial Number is ECC7-1C96
Directory of c:\downloads
File Not Found
Upvotes: 0
Views: 4148
Reputation: 14968
DIR is an internal command (see: https://ss64.com/nt/syntax-internal.html)
The following should work (untested):
c:\>SCHTASKS /Create /SC MINUTE /MO 1 /TN mydir /TR "cmd /c dir c:\windows > c:\downloads\temp_w.txt"
Upvotes: 1