China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-05 06:32
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Check if the drive letter exists, Call the script. View 1,806 Replies 3
Original Poster Posted 2006-09-21 05:34 ·  中国 江西 鹰潭 电信
中级用户
★★
Credits 244
Posts 92
Joined 2006-05-13 21:24
20-year member
UID 55477
Status Offline
@echo off
if exist d: call d.bat
if exist e: call e.bat
if exist f: call f.bat
if exist g: call g.bat
if exist h: call h.bat
if exist i: call i.bat
pause

_______________________________________________________
Content of D.bat

D:
for /f "tokens=*" %%i in ('dir /ad /b') do attrib +h "%%i"
_______________________________________________

The contents of other *.bat are all the same as D.bat, just with different drive letters.

Running result:
Only d.bat is called, and the other bats are not called.

Floor 2 Posted 2006-09-21 09:17 ·  中国 江西 鹰潭 电信
中级用户
★★
Credits 244
Posts 92
Joined 2006-05-13 21:24
20-year member
UID 55477
Status Offline
...Experts, please give guidance, why is this happening
Floor 3 Posted 2006-09-21 10:07 ·  中国 江西 鹰潭 电信
中级用户
★★
Credits 244
Posts 92
Joined 2006-05-13 21:24
20-year member
UID 55477
Status Offline
Solution. Hey...
When calling d.bat, it has already switched to the D drive directory
Then when calling e.bat, it can't be called. Need to switch back to the current directory
Floor 4 Posted 2007-06-30 11:17 ·  中国 浙江 嘉兴 海宁市 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
I tried it. No settings are needed at all, and the program can run all!
Forum Jump: