批处理文件以执行文件夹中的所有.exe [英] Batch File to execute all .exe in a folder

查看:671
本文介绍了批处理文件以执行文件夹中的所有.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个批处理脚本,该脚本将运行文件夹中的所有.exe文件.其中必须包含子文件夹.

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

我正在运行Windows 7,批处理文件存储在根文件夹中

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

我已经浏览了上述方法的几种变体,但没有任何效果.最高版本(我想避免)仅从文件中读取一行.底部版本在提示窗口中输出未修改的"dir"命令.

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.

推荐答案

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.

这篇关于批处理文件以执行文件夹中的所有.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆