带引号的 Schtasks.exe

Mar*_*ven 5 batch-file windows-task-scheduler

我使用此命令来创建任务: schtasks /Create /TN ITCMD-CHAT-NOTIF /SC ONLOGON /tr "%cd%\Notif\Notif.vbs" /F

然而出现了问题。当路径中有空格时,它仍然不会在操作周围添加引号。有没有办法在动作周围加上引号?

Wor*_*lle 7

这可以通过嵌套两个不同的引号字符来完成。("'随后'""\"随后\""

schtasks /Create /TN ITCMD-CHAT-NOTIF /SC ONLOGON /tr "'%cd%\Notif\Notif.vbs'" /F
Run Code Online (Sandbox Code Playgroud)

schtasks文档中:

==> Spaces in file paths can be used by using two sets of quotes, one
    set for CMD.EXE and one for SchTasks.exe.  The outer quotes for CMD
    need to be double quotes; the inner quotes can be single quotes or
    escaped double quotes:
    SCHTASKS /Create
       /tr "'c:\program files\internet explorer\iexplorer.exe'
       \"c:\log data\today.xml\"" ...
Run Code Online (Sandbox Code Playgroud)