如何使用带有空格的路径和命令的“start”在Windows中创建批处理文件

时间:2022-10-01 02:03:54

I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command.

我需要创建一个批处理文件,在Windows .cmd文件中启动多个控制台应用程序。这可以使用start命令完成。

However, the command has a path in it. I also need to pass paramaters which have spaces as well. How to do this?

但是,该命令中有一个路径。我还需要传递有空格的参数。这该怎么做?

E.g. batch file

例如。批处理文件

start "c:\path with spaces\app.exe" param1 "param with spaces"

7 个解决方案

#1


152  

Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "" before path to the app, it should work (at least it did for me). Use something like this:

实际上,他的例子不起作用(虽然起初我认为它也会这样)。根据Start命令的帮助,第一个参数是新创建的命令提示符窗口的名称,第二个和第三个参数应分别是应用程序及其参数的路径。如果你在应用程序的路径之前添加另一个“”,它应该工作(至少它对我来说)。使用这样的东西:

start "" "c:\path with spaces\app.exe" param1 "param with spaces"

You can change the first argument to be whatever you want the title of the new command prompt to be. If it's a Windows app that is created, then the command prompt won't be displayed, and the title won't matter.

您可以将第一个参数更改为您想要的新命令提示符的标题。如果它是创建的Windows应用程序,则不会显示命令提示符,并且标题无关紧要。

#2


15  

Escaping the path with apostrophes is correct, but the start command takes a parameter containing the title of the new window. This parameter is detected by the surrounding apostrophes, so your application is not executed.

使用撇号转义路径是正确的,但start命令采用包含新窗口标题的参数。此参数由周围的撇号检测,因此不会执行您的应用程序。

Try something like this:

尝试这样的事情:

start "Dummy Title" "c:\path with spaces\app.exe" param1 "param with spaces"

#3


1  

Interestingly, it seems that in Windows Embedded Compact 7, you cannot specify a title string. The first parameter has to be the command or program.

有趣的是,似乎在Windows Embedded Compact 7中,您无法指定标题字符串。第一个参数必须是命令或程序。

#4


1  

start "" "c:\path with spaces\app.exe" "C:\path parameter\param.exe"

When I used above suggestion, I've got:

当我使用上述建议时,我得到了:

'c:\path' is not recognized a an internal or external command, operable program or batch file.

'c:\ path'无法识别内部或外部命令,可运行程序或批处理文件。

I think second qoutation mark prevent command to run. After some search below solution save my day:

我认为第二个qoutation标记阻止命令运行。经过一些搜索下面的解决方案,节省了我

start "" CALL "c:\path with spaces\app.exe" "C:\path parameter\param.exe"

#5


0  

You are to use something like this:

你应该使用这样的东西:

start /d C:\Windows\System32\calc.exe

start / d C:\ Windows \ System32 \ calc.exe

start /d "C:\Program Files\Mozilla

start / d“C:\ Program Files \ Mozilla

Firefox" firefox.exe start /d

Firefox“firefox.exe start / d

"C:\Program Files\Microsoft

Office\Office12" EXCEL.EXE

Also I advice you to use special batch files editor - Dr.Batcher

另外我建议你使用特殊的批处理文件编辑器 - Dr.Batcher

#6


-1  

Surrounding the path and the argument with spaces inside quotes as in your example should do. The command may need to handle the quotes when the parameters are passed to it, but it usually is not a big deal.

如示例所示,在路径和带引号内的空格的参数周围应该这样做。当参数传递给它时,命令可能需要处理引号,但这通常不是什么大问题。

#7


-1  

I researched successfully and it is working fine for me. My requirement is to sent an email using vbscript which needs to be call from a batch file in windows. Here is the exact command I am using with no errors.

我研究成功,它对我来说很好。我的要求是使用vbscript发送一封电子邮件,需要从windows中的批处理文件调用。这是我正在使用的确切命令,没有错误。

START C:\Windows\System32\cscript.exe "C:\Documents and Settings\akapoor\Desktop\Mail.vbs"

#1


152  

Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "" before path to the app, it should work (at least it did for me). Use something like this:

实际上,他的例子不起作用(虽然起初我认为它也会这样)。根据Start命令的帮助,第一个参数是新创建的命令提示符窗口的名称,第二个和第三个参数应分别是应用程序及其参数的路径。如果你在应用程序的路径之前添加另一个“”,它应该工作(至少它对我来说)。使用这样的东西:

start "" "c:\path with spaces\app.exe" param1 "param with spaces"

You can change the first argument to be whatever you want the title of the new command prompt to be. If it's a Windows app that is created, then the command prompt won't be displayed, and the title won't matter.

您可以将第一个参数更改为您想要的新命令提示符的标题。如果它是创建的Windows应用程序,则不会显示命令提示符,并且标题无关紧要。

#2


15  

Escaping the path with apostrophes is correct, but the start command takes a parameter containing the title of the new window. This parameter is detected by the surrounding apostrophes, so your application is not executed.

使用撇号转义路径是正确的,但start命令采用包含新窗口标题的参数。此参数由周围的撇号检测,因此不会执行您的应用程序。

Try something like this:

尝试这样的事情:

start "Dummy Title" "c:\path with spaces\app.exe" param1 "param with spaces"

#3


1  

Interestingly, it seems that in Windows Embedded Compact 7, you cannot specify a title string. The first parameter has to be the command or program.

有趣的是,似乎在Windows Embedded Compact 7中,您无法指定标题字符串。第一个参数必须是命令或程序。

#4


1  

start "" "c:\path with spaces\app.exe" "C:\path parameter\param.exe"

When I used above suggestion, I've got:

当我使用上述建议时,我得到了:

'c:\path' is not recognized a an internal or external command, operable program or batch file.

'c:\ path'无法识别内部或外部命令,可运行程序或批处理文件。

I think second qoutation mark prevent command to run. After some search below solution save my day:

我认为第二个qoutation标记阻止命令运行。经过一些搜索下面的解决方案,节省了我

start "" CALL "c:\path with spaces\app.exe" "C:\path parameter\param.exe"

#5


0  

You are to use something like this:

你应该使用这样的东西:

start /d C:\Windows\System32\calc.exe

start / d C:\ Windows \ System32 \ calc.exe

start /d "C:\Program Files\Mozilla

start / d“C:\ Program Files \ Mozilla

Firefox" firefox.exe start /d

Firefox“firefox.exe start / d

"C:\Program Files\Microsoft

Office\Office12" EXCEL.EXE

Also I advice you to use special batch files editor - Dr.Batcher

另外我建议你使用特殊的批处理文件编辑器 - Dr.Batcher

#6


-1  

Surrounding the path and the argument with spaces inside quotes as in your example should do. The command may need to handle the quotes when the parameters are passed to it, but it usually is not a big deal.

如示例所示,在路径和带引号内的空格的参数周围应该这样做。当参数传递给它时,命令可能需要处理引号,但这通常不是什么大问题。

#7


-1  

I researched successfully and it is working fine for me. My requirement is to sent an email using vbscript which needs to be call from a batch file in windows. Here is the exact command I am using with no errors.

我研究成功,它对我来说很好。我的要求是使用vbscript发送一封电子邮件,需要从windows中的批处理文件调用。这是我正在使用的确切命令,没有错误。

START C:\Windows\System32\cscript.exe "C:\Documents and Settings\akapoor\Desktop\Mail.vbs"