【发布时间】:2015-05-05 20:21:05
【问题描述】:
目前我有这个:
for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist "%%d\Program Files (x86)\Folder": (
cd "%%d\Program Files (x86)\Folder\subfolder\file"
)
)
但它似乎不起作用。我希望批处理脚本搜索驱动器中是否存在某个程序的子文件夹,然后 cd 到 .ini 文件的位置(如果有的话)。该文件也可能位于 /program files/ 以外的位置,即它可能位于 driveletter:\Folder。
非常感谢任何帮助!
【问题讨论】:
-
你有
programfiles(x86)和programfiles变量,你不需要遍历所有字母... -
我将其放入 cmets 是因为您特别要求提供
.bat文件,但我建议您改为考虑使用 powershell。 -
该文件可能不在其中任何一个中,这是一个示例。
-
出于安全原因,这些机器上不允许使用 Powershell :( 如果是我会使用它。
标签: windows batch-file scripting