iT邦幫忙

0

Dos start 執行不同資料夾內的執行檔

請問一下

關於start
我原本的狀態在c:
下了如下的指令
for /r d:\file %i (purge.exe) do start %i
https://ithelp.ithome.com.tw/upload/images/20210222/20135214j2PiVTKiIX.jpg
但實際上並沒有真的去執行d:\file 下的每個一執行檔
而是只執行c:\purge.exe
可以請問這種問題有解法嘛??

for /r %i in (*.exe) do (echo %i)
for /r %i in (*.exe) do (start %i)
呃改錯個了.
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
japhenchen
iT邦超人 1 級 ‧ 2021-02-22 10:38:47

修正成以下,試試

@echo off 
FOR /R d:\file %%a in (purge.exe) do (
    if exist %%a (
        start %%a
    )
)
看更多先前的回應...收起先前的回應...

我用

FOR /R c:\windows %%a in (calc.exe) 測試過
會執行4個不同的小算盤的版本
https://ithelp.ithome.com.tw/upload/images/20210222/20117954AeDdUTcJAo.jpg

jw_lee iT邦新手 5 級 ‧ 2021-02-22 13:15:00 檢舉

@echo off
FOR /R d:\file %%a in (purge.exe) do (
if exist %%a (
start %%a
)
)

hi
這個也只會執行d:\file 下的purge.exe
並沒有真的去執行d:\file 的2561 2726兩個資料夾的purge.exe
您還有其他方法可以幫忙我嘛??

咦?我執行是OK的啊,你把start %%a改成echo %%a看看,會是你的Windows/DOS的版本過舊的問題嗎?你用的版本是?我的是Windows10 20H2

你用powershell試試,命令列模式下的for曾有改版過,不知是否我的做法是新增的做法

jw_lee iT邦新手 5 級 ‧ 2021-02-22 19:34:15 檢舉

hi japhenchen
我的版本也是20H2
也是不行耶
@echo off
FOR /R d:\file %%a in (purge.exe) do (
if exist %%a (
powershell %%a
)
)
powershell 也是能執行d:\file 下的purge.exe
d:\file 的2561 2726兩個資料夾的purge.exe還是不行
方便給我 您的email我把相關的檔案寄給您
冒昧請見諒

我要發表回答

立即登入回答