php 在批处理文件中运行带有参数的exe文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23112377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run exe file with parameters in a batch file
提问by user1421214
Please have a look at my batch file.
请看看我的批处理文件。
echo off
start "c:\program files\php\php.exe D:\mydocs\mp\index.php param1 param2"
but it isn't working. Any ideas how do I get it working?
但它不起作用。任何想法如何让它工作?
回答by nobody
This should work:
这应该有效:
start "" "c:\program files\php\php.exe" D:\mydocs\mp\index.php param1 param2
The start
command interprets the first argument as a window title if it contains spaces. In this case, that means start
considers your whole argument a title and sees no command. Passing ""
(an empty title) as the first argument to start
fixes the problem.
如果start
第一个参数包含空格,该命令会将第一个参数解释为窗口标题。在这种情况下,这意味着start
将您的整个论点视为标题并且看不到命令。传递""
(空标题)作为start
解决问题的第一个参数。
回答by Scopperloit
If you need to see the output of the execute, use CALL
together with or instead of START
.
如果您需要查看执行的输出,请CALL
与 或 代替 一起使用START
。
Example:
例子:
CALL "C:\Program Files\Certain Directory\file.exe" -param
PAUSE
CALL "C:\Program Files\Certain Directory\file.exe" -param
PAUSE
This will run the file.exe and print back whatever it outputs, in the same command window. Remember the PAUSE
after the call or else the window may close instantly.
这将运行 file.exe 并在同一个命令窗口中打印回它输出的任何内容。记住PAUSE
调用后,否则窗口可能会立即关闭。
回答by álvaro González
Unless it's just a simplified example for the question, my advice is that drop the batch wrapper and schedule PHP directly, more specifically the php-win.exe
program, which won't open unnecessary windows.
除非这只是问题的一个简化示例,否则我的建议是删除批处理包装器并直接调度 PHP,更具体地说是php-win.exe
程序,它不会打开不必要的窗口。
Program: c:\program files\php\php-win.exe
Arguments: D:\mydocs\mp\index.php param1 param2
Otherwise, just quote stuff as Andrew points out.
否则,只需引用安德鲁指出的内容。
In older versions of Windows, you should be able to put everything in the single "Run" text box (as long as you quote everything that has spaces):
在旧版本的 Windows 中,您应该能够将所有内容放在单个“运行”文本框中(只要您引用所有包含空格的内容):
"c:\program files\php\php-win.exe" D:\mydocs\mp\index.php param1 param2