开发者

SchTask with XCOPY command

开发者 https://www.devze.com 2023-03-06 05:51 出处:网络
I am creating an installation script for our web panel software, but I don\'t do too many batch scripts. I need to keep this all in the same file (can\'t seperate it out) so how exactly can I do this?

I am creating an installation script for our web panel software, but I don't do too many batch scripts. I need to keep this all in the same file (can't seperate it out) so how exactly can I do this?

SchTasks /Create开发者_如何学JAVA /SC DAILY /TN "%ip%%port%-PB" /TR "XCOPY /D /E /C /R /K /Y "%userfilespath%\pb\*.*" "C:\PBScreens\%ip%%port%\"" /ST 00:00

I am assuming I can't put the source and target directories in quotation marks since the /TR switch is in quotations. Can I put it in '' or how do I do this?

Thanks!


The problem is with quotes and spaces in the /TR (taskrun) parameter of schtasks.

You need to enclose the complete taskrun parameter in quotes and escape all the quotes inside it with backslashes (\).

Carefully test this

set taskname="%ip%-%port%-PB"
set taskrun="XCOPY /D /E /C /R /K /Y \"%userpath%\pb\*.*\" \"%destpath%\%ip%%port%\\"" 
SchTasks /Create /SC DAILY /TN %taskname% /TR %taskrun% /ST 00:00:00
0

精彩评论

暂无评论...
验证码 换一张
取 消