Sign in to follow this  
Followers 0
jflores

Problem creating a Schedule Task

4 posts in this topic

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

Share this post


Link to post
Share on other sites



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

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')

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0