jflores Posted August 5, 2010 Share Posted August 5, 2010 I am working on a script to create a schedule task that runs once a month on day 20. The script creates the task but in the run window it is adding "C:\Documents and Settings\userid\Desktop\task\'C:\WINDOWS\system32\defrag.exe" %homedrive% Which causes the task to not run. I need it to just put in C:\WINDOWS\system32\defrag.exe" %homedrive%. What am I doing wrong? Below is the code I am using runwait ("schtasks /create /RU SYSTEM /SC monthly /D 20 /TN ""Monthly Defrag"" /TR ""'%systemroot%\system32\defrag.exe %homedrive%"" /ST 01:00:00") Thanks for your help Link to comment Share on other sites More sharing options...
Bert Posted August 5, 2010 Share Posted August 5, 2010 http://technet.microsoft.com/en-us/library/cc772785%28WS.10%29.aspx The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Jim Dandy Posted August 7, 2010 Share Posted August 7, 2010 I am working on a script to create a schedule task that runs once a month on day 20.The script creates the task but in the run window it is adding "C:\Documents and Settings\userid\Desktop\task\'C:\WINDOWS\system32\defrag.exe" %homedrive%Which causes the task to not run.I need it to just put in C:\WINDOWS\system32\defrag.exe" %homedrive%.What am I doing wrong?Below is the code I am usingrunwait ("schtasks /create /RU SYSTEM /SC monthly /D 20 /TN ""Monthly Defrag"" /TR ""'%systemroot%\system32\defrag.exe %homedrive%"" /ST 01:00:00")Thanks for your helpYou have an extra single quote right before %systemroot%. If you enclose your statement in single quotes, you can avoid using double-double quotes.For example:RunWait('schtasks /create /RU SYSTEM /SC monthly /D 20 /TN "Monthly Defrag" /TR "%systemroot%\system32\defrag.exe %homedrive%" /ST 01:00:00') Link to comment Share on other sites More sharing options...
jflores Posted August 9, 2010 Author Share Posted August 9, 2010 You have an extra single quote right before %systemroot%. If you enclose your statement in single quotes, you can avoid using double-double quotes.For example:RunWait('schtasks /create /RU SYSTEM /SC monthly /D 20 /TN "Monthly Defrag" /TR "%systemroot%\system32\defrag.exe %homedrive%" /ST 01:00:00')That worked, Thanks for your help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now