Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All ,

How are You ??

I have created a Windows Task named "MytestTask"

and I am executing the following code for running the task ,I dont know why it is not working

**************************************************
C#
 protected void Button1_Click(object sender, EventArgs e)
    {
        var p = new Process
       {
           StartInfo =
           {
               UseShellExecute = false,
               FileName = "SCHTASKS",
               RedirectStandardError = true,
               RedirectStandardOutput = true,
               CreateNoWindow = true,
               WindowStyle = ProcessWindowStyle.Hidden,
               Arguments = "/Run/TN MytestTask"
           }
       };
       p.Start();
}


***********************************************************

Can anyone tell me where i missed ???
Thanks
sreejesh
Posted
Comments
phil.o 24-Apr-14 6:15am    
Please define 'not working'.
ali_1 24-Apr-14 7:20am    
Not working means I cannot run the Scheduled task.. Griff below saying for using username and password also i have used SCHTASKS.exe ,but still not working ?? can you guess where could be the problm?

1 solution

Probably, it's your arguments: Look at the documentation and I suspect your "/Run/TN" part ios wrong: RUN needs a username which doesn't seem to be optional.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357(v=vs.85).aspx[^]

I would also suggest that you add the path to your EXE file, as otherwise it may not find it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900