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
精彩评论