来源:蜘蛛抓取(WebSpider)
时间:2017-08-21 18:50
标签:
计划任务运行结果0x2
schtasks 命令创建计划任务,路径含有空格的解决办法
&&& 想通过 schtasks 命令创建计划任务,通过计划任务执行安装目录下的某个批处理文件,但是该批处理文件的绝对路径中包含空格,创建成功后执行报错&未能执行&。
&&& 网上搜了一下,基本上是这个方法解决
&&&&[注意:a. 命令行创建的计划任务有空格而不能创建的情况的解决方案:在含有看空格的参数或则路径前面加上 /&&&进行转义,这样就ok&&&&&&&&&demo:& schtasks /create&/sc minute&/mo&30 /tn &finaltest& /tr /&d:program file/smth.bat& /&'20'&'302'&&&&&------------------ 14:22]
&& 看的我是一头雾水,实际使用也是能创建成功,不能执行。
&&&最后在微软帮助支持里找到了正确的解决办法。
&&&原文如下:
&&&【 This problem occurs if the path of the scheduled task contains a space. For example, this problem occurs if you create a schedule for the following task by using Schtasks.exe:
&c:\foldername containing spaces\task.bat&
In this example, Schtasks.exe treats everything after the first space in the path as a command-line argument.
&&& When you use the Scheduled Tasks Wizard to schedule a task, the task runs as you expect. However, if you use the Schtasks.exe command-line tool to create a schedule for the same task, the task does not run at the time when you scheduled it. Additionally, when you view the task in the Scheduled Tasks dialog box, the following text appears in the Status column:
Could not start
&&& To work around this problem, enclose the path portion of the task (not including arguments or switches) between backslash (\) and quotation marks (&) character combinations, for example \&. Enclose the complete path of the task (including arguments or switches) between quotation marks as usual when you create a path or command that contains spaces. &&& For example, the following example task does not run when you schedule it:
schtasks /create /tn &my task& /tr &c:\foldername containing spaces\script.bat arguments& /sc once /sd 07/29/2003 /st 10:01
&&& However, when you enclose the path of the task between the backslash and quotation marks character combinations as in the following example, the scheduled task runs successfully:
schtasks /create /tn &my task& /tr &\&c:\foldername name containing spaces\script.bat\& arguments& /sc once /sd 07/29/2003 /st 10:01 】
&&& 解释一下: 通过【\&】将包含空格的路径包括起来, 然后外层再加上引号【&】。
&&& 例子:
&&& 【schtasks /create /tn &orientsch& /ru &System& /sc WEEKLY /d FRI /st 11:35:01 /tr& &\&c:\Lee gb\test.bat\&&】
&&最后修改于
请各位遵纪守法并注意语言文明通过计划任务SCHTASKS远程启用Remoting
- PowerShell 中文博客Schtasks 锟斤拷签_51CTO锟斤拷锟斤拷锟斤拷锟斤拷
搜索推荐文章
搜索原创文章
搜索近期文章
&&&&schtasks/create/scminute/mo5/tntestname/tr"cmd/cnltest/&&c:\temp\testlog.txt"