views:

37

answers:

3

I have a C#.net app I need to run off a computer. It has to be scheduled. I am using Windows XP Professional and the app is in C#.net. I have attempted to schedule the job, but I think my syntax is wrong. I would appreciate any help in getting it corrected. The c# exe file is on the c drive of the computer, and in order for it to work properly, I need to pass in a variable of "autorun". Otherwise it will pull up a menu, and I don't want that.

My Run code in the scheduler is:

C:\\Windows\System32\cscript.exe C:\Program Files\Paper\Paper.exe /autorun

It does something, but the exe creates an excel file that is never created, so it isn't running properly. If I run the exe manually it works fine, so it seems like my problem is in the way I scheduled the task. Any help would be appreciated.

+1  A: 

I think your filepath needs to be inside "". Experiment, but I think your first part needs to be inside quotes and your options need to be without quotes.

rmx
A: 

Why not create a batch file that contains the following:

C:\Program Files\Paper\Paper.exe /autorun

Then call the the batch file in the scheduler:

C:\Windows\System32\csript.exe BatchFile.bat

Failing that put quotes round the path to the exe:

C:\Windows\System32\csript.exe "C:\Program Files\Paper\Paper.exe" /autorun

otherwise it will treat "C:\Program" and "Files\Paper\Paper.exe" as separate arguments.

ChrisF
We tried a batch file and had the same problem. Turns out the /autorun was part of the problem. apparently C# and DOS have a problem with the / so we removed it and did it as autorun and it worked. Thank you for helping!
Azzna
+1  A: 

CScript.exe is the Console Windows Scripting Host interpreter. You need to pass scripts files to it like VBS or JS files.

It is probably failing silently in the background with a message saying it can't understand the script file because what you are supplying cscript is an exe.

Do not bother with cscript as unless something is missing in the question, you most likely do not need this and is the reason to your problems.

Just setting "C:\Program Files\Paper\Paper.exe" /autorun in the Task Scheduler should work.

Kharlos Dominguez
We took out the CScript.exe and that helped. Turns out C# and DOS together don't like / so when I took that out before the Autorun and removed the CScript.exe it ran. Thank you so much!
Azzna