How to loop through drive letters to run my script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
kingofdos
Posts: 8
Joined: 14 Dec 2022 23:02

Re: How to loop through drive letters to run my script

#16 Post by kingofdos » 03 Jan 2023 16:26

Code: Select all

---
The system cannot find the path specified.
The system cannot find the path specified.
---
The system cannot find the path specified.
The system cannot find the path specified.
---
 Volume in drive E is Seagate Skyhawk 3TB
 Volume Serial Number is AA95-32F6

 Directory of E:\Dropbox\AHK

23-01-04  06:20 am           198,112 AutoHotKey.ahk
               1 File(s)        198,112 bytes
               0 Dir(s)  773,411,139,584 bytes free
 Volume in drive E is Seagate Skyhawk 3TB
 Volume Serial Number is AA95-32F6

 Directory of E:\Dropbox\AHK

23-01-03  04:09 pm           105,669 TextExpansion.ahk
               1 File(s)        105,669 bytes
               0 Dir(s)  773,411,139,584 bytes free
---
The device is not ready.
The device is not ready.
Press any key to continue . . .

miskox
Posts: 553
Joined: 28 Jun 2010 03:46

Re: How to loop through drive letters to run my script

#17 Post by miskox » 05 Jan 2023 05:23

Here we see that both scripts are there. Go to command prompt and type:

Code: Select all

E:\Dropbox\AHK\AutoHotKey.ahk (and press RETURN)
What happens? Does it return to the prompt immediately (while the script is still running)?

Code: Select all

E:\Dropbox\AHK\TextExpansion.ahk (and press RETURN)
Is everything as expected?

Create new .bat file test.bat:

Code: Select all

@E:\Dropbox\AHK\AutoHotKey.ahk
@E:\Dropbox\AHK\TextExpansion.ahk
Run this code from the command prompt. Is everything as expected?

I see no reason why my program should not work.

Code: Select all

@echo off
for %%f in (C D E F) do if exist "%%f:\Dropbox\AHK\Autohotkey.ahk" if exist "%%f:\Dropbox\AHK\TextExpansion.ahk" (
	title Running %%f: Autohotkey.ahk
	start "" /wait /b cmd /c "%%f:\Dropbox\AHK\Autohotkey.ahk"
	title Running %%f: TextExpansion.ahk
	start "" /wait /b cmd /c "%%f:\Dropbox\AHK\TextExpansion.ahk"
)
echo Done.
pause
Saso

Post Reply