2012-04-16 119 views
1

在我的应用程序中,我传递了一些命令行参数来安排任务。
str是成为
在命令行参数中传递应用程序的路径

/create /tn StartIE /tr "C:\Program Files\Internet Explorer\iexplore.exe http://abc.com" /sc onlogon 

一些操作后一个字符串,然后我开始的过程为:

ProcessStartInfo ps = ProcessStartInfo("schtasks"); 
ps.Arguments = str; 
Process.Start(ps); 

当我看着为计划任务的任务scheudler,我得到行动的时间表任务为:

C:\Program 
and the Arguments as: Files\Internet Explorer\iexplore.exe http://abc.com 

所以,问题是因为空间程序文件。我该如何纠正一件事情,以便实际的程序仍然是
C:\Program Files\Internet Explorer\iexplore.exe http://abc.com
Arguments = http://abc.com

回答

0

我相信你需要通过你的报价逃脱,以便他们可以'提取'schtasks过程。您的字符串应该结束了含:

/create /tn StartIE /tr "C:\Program Files\Internet Explorer\iexplore.exe http://abc.com" /sc onlogon

但我怀疑它实际上包含:

/create /tn StartIE /tr \""C:\Program Files\Internet Explorer\iexplore.exe http://abc.com\"" /sc onlogon

/create /tn StartIE /tr C:\Program Files\Internet Explorer\iexplore.exe http://abc.com /sc onlogon

当你创建你应该靶向这意味着

类似的问题和答案:Why "schtasks" does not run my job?

相关问题