How do I use quotes in cmd start?

倾然丶 夕夏残阳落幕 提交于 2020-07-06 09:53:26

问题


Here somthing I want to do.

start /wait ((c:\Program Files\NetDrive2\nd2cmd.exe) -c m -t ftp -blabla)

If I do

start /wait "c:\Program Files\NetDrive2\nd2cmd.exe -c m -t ftp -blabla"

Then there is an error because "Program Files" has a space.

If I do

start /wait "c:\Program Files\NetDrive2\nd2cmd.exe" -c m -t ftp -blabla

Then it interprets the argument for start so it also generates an error.

Is there anyway to overlap the equation like bracket in normal program language?


回答1:


Reference Start - Start a program, command or batch script (opens in a new window.)

Syntax

START "title" [/D path] [options] "command" [parameters]

Key:

title Text for the CMD window title bar (required.)

path Starting directory.

command The command, batch file or executable program to run.

parameters The parameters passed to the command.

...

Always include a TITLE this can be a simple string like "My Script" or just a pair of empty quotes "". According to the Microsoft documentation, the title is optional, but you may will have problems if it is omitted.

The reason you have an error if title is omitted is because the first " character (if present) will be used to delimit the title, so start will interpret "Program Files" as a title.

If there are no " characters then title can be omitted.

Your command should look like:

start /wait "My title" "c:\Program Files\NetDrive2\nd2cmd.exe" -c m -t ftp -blabla


来源:https://stackoverflow.com/questions/27261692/how-do-i-use-quotes-in-cmd-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!