Windows XP 调度程序调用需要传递变量的 C# 应用程序时出现问题
我有一个 C#.net 应用程序,需要在计算机上运行。它必须被安排。我使用的是 Windows XP Professional,该应用程序位于 C#.net 中。我试图安排这项工作,但我认为我的语法是错误的。我将不胜感激任何帮助纠正它的帮助。 c# exe文件位于计算机的c盘上,为了使其正常工作,我需要传入一个“autorun”变量。否则它会弹出一个菜单,而我不想要这样。
我在调度程序中的运行代码是:
C:\\Windows\System32\cscript.exe C:\Program Files\Paper\Paper.exe /autorun
它做了一些事情,但是 exe 创建了一个从未创建的 excel 文件,因此它无法正常运行。如果我手动运行该exe,它工作正常,所以看来我的问题出在我安排任务的方式上。任何帮助将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
CScript.exe 是控制台 Windows 脚本宿主解释器。您需要向其传递脚本文件,例如 VBS 或 JS 文件。
它可能在后台默默地失败,并显示一条消息,指出它无法理解脚本文件,因为您提供的 cscript 是一个 exe。
不要打扰 cscript,因为除非问题中缺少某些内容,否则您很可能不需要它,并且这就是您问题的原因。
只需在任务计划程序中设置“C:\Program Files\Paper\Paper.exe”/autorun 就可以了。
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.
我认为您的文件路径需要位于
""
内。实验,但我认为你的第一部分需要在引号内,而你的选项需要不带引号。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.为什么不创建一个包含以下内容的批处理文件:
然后调用调度程序中的批处理文件:
未能在 exe 路径周围添加引号:
否则它将把 "C:\Program" 和 "Files\Paper\Paper.exe" 视为单独的参数。
Why not create a batch file that contains the following:
Then call the the batch file in the scheduler:
Failing that put quotes round the path to the exe:
otherwise it will treat "C:\Program" and "Files\Paper\Paper.exe" as separate arguments.