I am getting "ERROR: Network path was not found" when I try to create a scheduled task on my local machine. I am using this command at the command prompt: schtasks /tn taskname /tr taskpath /sc minute /mo 20 /sd 09/23/2010 /s \\%computername% /u username /p password

When I give the above command without computername, username and password the task gets created perfectly fine. What am I doing wrong??

EDIT : I got it working by using the below command. I do not understand why it is working becuase I am using /ru and /rp which are remote user and remote password settings whereas I am executing the command on my local machine. And I had to give double quotes to computername.

schtasks /tn taskname /tr taskpath /sc minute /mo 20 /sd 09/23/2010 /s "%computername%" /ru username /rp password
link|improve this question
feedback

2 Answers

up vote 0 down vote accepted

I believe if you are trying to run that command as written, the target machine %computername% will alway return your local machine name. By default schtasks works locally, unless you specify a remote machine with /s.

Now, if the command you are running is /s remotemachine, and you get that error, I believe the \\ is not necessary. Here are some examples.

Hope this helps.

link|improve this answer
I am running that command on my local machine only. I am not doing from remote computer. Although I am accessing the computer through remote access. my computer name has a hyphen "-" in it. Do you think becuase of hyphen I am getting this error? – user50273 Sep 24 '10 at 14:06
Why I am saying about hyphen because, I ran the same command on another system and its working fine. – user50273 Sep 24 '10 at 14:08
I guess the hyphen was escaped by the double quotes. The /ru & /rp are probably needed for the /s. If you are running the task on the local machine, you could probably get away with not using /s (and computer name) and change the /ru and /rp to /u and /p. I guess you need the task to run under alternate credentials and that is why you took the route you did. – Scott McClenning Sep 24 '10 at 23:25
feedback

In the /tr taskpath argument, does the path contain any spaces? If so, surround the path with double quotes ". So instead of /tr c:\program files\test\run.exe you would use
/tr "c:\program files\test\run.exe".

link|improve this answer
the path where exe is located has no spaces. – user50273 Sep 24 '10 at 14:07
Is there any way you could post the actual command you're using? – boot13 Sep 24 '10 at 14:46
schtasks /create /tn MyApp /tr C:\Inetpub\wwwroot\WebApp\bin\MyApp.exe /sc minute /mo 20 /sd 09/24/2010 /s \\%computername% /u username /p password – user50273 Sep 24 '10 at 14:53
I just got the schedule task created by using /ru and /rp settings instead of /u and /p. This command created the schedule task. I have no freaking idea why. "schtasks /create /tn MyApp /tr C:\Inetpub\wwwroot\WebApp\bin\MyApp.exe /sc minute /mo 20 /sd 09/24/2010 /ru username /rp password" – user50273 Sep 24 '10 at 14:54
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.