简体   繁体   English

批处理文件以执行文件夹中的所有 .exe

[英]Batch File to execute all .exe in a folder

I need to create a batch script that will run all .exe files in a folder.我需要创建一个批处理脚本来运行文件夹中的所有 .exe 文件。 This must include subfolders.这必须包括子文件夹。

I am running windows 7, and the batch file is stored in the root folder我正在运行 Windows 7,批处理文件存储在根文件夹中

I have tried several variations with no success.我尝试了几种变体,但都没有成功。 The two main variations are as follows两个主要变化如下

REM dir *.exe /S /B > tmpFile
REM set /p listVar= < tmpFile
REM del tmpFile

FOR %%F IN (%listVar%) DO %%F

======================================= ========================================

FOR /F "usebackq" %%F IN ('dir *.exe /S /B') DO %%F

I have looked through several variations on the above methods but none work.我已经查看了上述方法的几种变体,但都没有奏效。 The top version (which I would like to avoid) only reads in one line from the file.最高版本(我想避免)只从文件中读取一行。 The Bottom version outputs an unmodified "dir" command in the prompt window.底部版本在提示窗口中输出未修改的“dir”命令。

Ultimately I would like help identifying how to solve this issue without the need for a temp file.最终,我想帮助确定如何在不需要临时文件的情况下解决这个问题。

for /r "." %%a in (*.exe) do start "" "%%~fa"

This will start all the executable files under the current folder and subfolders.这将启动当前文件夹和子文件夹下的所有可执行文件。 Change the reference to the current folder ( "." ) to your needs.根据您的需要更改对当前文件夹 ( "." ) 的引用。

for %1 in (%USERPROFILE%\*.exe) do "%1"

This will start all executables in your user folder.这将启动用户文件夹中的所有可执行文件。 Of course, that includes installers and stuff like that, and you probably don't want to reinstall all your apps, so replace %USERPROFILE% with the directory you want.当然,这包括安装程序和类似的东西,您可能不想重新安装所有应用程序,因此将%USERPROFILE%替换为您想要的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM