Batch File to execute all .exe in a folder

拜拜、爱过 提交于 2020-01-12 06:14:14

问题


I need to create a batch script that will run all .exe files in a folder. This must include subfolders.

I am running windows 7, and the batch file is stored in the root folder

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.

Ultimately I would like help identifying how to solve this issue without the need for a temp file.


回答1:


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.



来源:https://stackoverflow.com/questions/26139456/batch-file-to-execute-all-exe-in-a-folder

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