[英]How to execute any .exe by using a batch file?
I know that I can start an exe by doing: 我知道我可以通过以下方式启动exe:
start "" /b filename.exe
But that requires me to know the name of filename.exe, how could I do that for any general file ending with .exe? 但这需要我知道filename.exe的名称,我怎么能为任何以.exe结尾的常规文件做到这一点? I tried the obvious wildcard implementation:
我尝试了明显的通配符实现:
start "" /b *.exe
Windows, however, gives me an error saying it cannot find "*.exe" file. 但是,Windows给出了一个错误,说它无法找到“* .exe”文件。
if you plan to run inside a batch file you can do in this way: 如果您打算在批处理文件中运行,可以这样做:
for %%i in (*.exe) do start "" /b "%%i"
if you want to skip a particular file to be executed: 如果要跳过要执行的特定文件:
for %%i in (*.exe) do if not "%%~nxi" == "blabla.exe" start "" /b "%%i"
if is necessary to check also the subfolders add the /r parameter: 如果有必要检查子文件夹添加/ r参数:
for /r %%i in (*.exe) do start "" /b "%%i"
从cmd运行此文件到包含您希望运行的所有exe
的文件夹:
for %x in (*.exe) do ( start "" /b "%x" )
Hoep it helps 嘻嘻有帮助
for /f "delims=" %%a in ('dir /b /s "*.exe"') do (
start %%a
)
You should first use dir command to find all exe files, and then execute it. 您应该首先使用dir命令查找所有exe文件,然后执行它。
In a bat file add this line 在bat文件中添加此行
FOR /F "tokens=4" %%G IN ('dir /A-D /-C ^| find ".exe"') DO start "" /b %%G
This execute every .exe file in your current directory. 这将执行当前目录中的每个.exe文件。 same as
如同
*.exe
would have done if * were supported on batch. 如果批量支持*,我会做的。
If you want to execute it directly from a command line window, just do 如果要直接从命令行窗口执行它,只需执行
FOR /F "tokens=4" %G IN ('dir /A-D /-C ^| find ".exe"') DO start "" /b %G
Don't blame their codes for space issue. 不要因为空间问题而责怪他们的代码。 You should know how to use double quotation marks.
您应该知道如何使用双引号。
for /f "delims=" %%a in ('dir /b /s *.exe') do (
start "" "%%a"
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.