題 帶引號的Schtasks.exe


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

但是會出現問題。當路徑中有空格時,它仍然不會在操作周圍放置引號。有沒有辦法在行動中加註?


2
2017-10-02 14:31


起源




答案:


這可以通過嵌套兩個不同的引號字符來實現。 ("' 其次是 '" 要么 "\" 其次是 \""

schtasks /Create /TN ITCMD-CHAT-NOTIF /SC ONLOGON /tr "'%cd%\Notif\Notif.vbs'" /F

來自 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\"" ...

3
2017-10-02 21:06



幹得好,我也準備好更詳細地看一下!! - Pimp Juice IT