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-07-01 09:03
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » What's wrong with this autoexec.bat? View 1,950 Replies 26
Original Poster Posted 2007-04-20 07:43 ·  中国 江苏 常州 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Contents of autoexec.bat (fragment)
@ECHO OFF
FOR %%a IN (A: C:) DO IF EXIST SET ud=%%a
mem /c|tfind /i "TW">nul
if not errorlevel 1 goto mo
lh %ud%\dos\tw /np N3 >nul
:mo
SET DIRCMD=/OGN /4
SET PROMPT=$P$G
SET HDPMI=16384
SET RAMDRIVE=x:\
XMSDSK 20480 %RAMDRIVE% /y>NUL
PATH=%RAMDRIVE%;%ud%\;%ud%\dos;
COPY %ud%\dos\COMMAND.COM %RAMDRIVE%>NUL
SET COMSPEC=%RAMDRIVE%COMMAND.COM
MD %RAMDRIVE%TEMP
SET TEMP=%RAMDRIVE%TEMP
CD>%TEMP%\BOOTDRV.INI
vol>%TEMP%\VOL.TXT
cls
call w.bat box (+white on +blue) @%ud%\dos\dos.scr:start
if errorlevel 100 goto end
if errorlevel 4 goto re
if errorlevel 3 goto end
if errorlevel 2 goto wdos
menu..bat
Below is part of menu.bat:
IF EXIST %RAMDRIVE%dos\gho.bat goto gh
IF NOT EXIST %RAMDRIVE%unzip.exe copy %ud%\dos\unzip.exe %RAMDRIVE%unzip.exe
IF EXIST %ud%\dos\gho.ex_ copy %ud%\dos\gho.ex_ %RAMDRIVE%gho.zip>NUL
PATH=%PATH%;%RAMDRIVE%gho\;
%RAMDRIVE%
cd\
unzip -d gho.zip >nul
del gho.zip >nul
:gh
gho.bat

It stops when it gets to cd\ . At this point there is unzip and gho.zip in %RAMDRIVE%, but it just won't extract.

After extracting manually, the original PATH becomes invalid; it says file not found (the file is in %ud%\dos)
Floor 2 Posted 2007-04-20 07:58 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
My level is limited, I can't see the problem either.
I don't see any directory in the virtual drive, so you might as well just remove cd\.
Windows 一键还原
http://www.yjhy.com
Floor 3 Posted 2007-04-20 08:03 ·  中国 江苏 常州 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
What gho.zip extracts to is a directory
Floor 4 Posted 2007-04-20 08:57 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
The problem is that your cd\ is before the extraction.
Windows 一键还原
http://www.yjhy.com
Floor 5 Posted 2007-04-20 08:58 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
del >nul
???
This line isn't right either, is it?
Windows 一键还原
http://www.yjhy.com
Floor 6 Posted 2007-04-20 09:08 ·  中国 黑龙江 哈尔滨 电信
高级用户
★★★
Credits 760
Posts 357
Joined 2005-10-10 22:33
20-year member
UID 43332
Status Offline
FOR %%a IN (A: C:) DO IF EXIST SET ud=%%a

This is wrong here!
If you're checking the boot drive letter, I suggest using the volume label to determine it, that is, give your IMG a fixed volume label!

Or use CD>%TEMP%\BOOTDRV.INI to determine it.

[ Last edited by 0451lym on 2007-4-20 at 09:14 AM ]
Floor 7 Posted 2007-04-20 09:29 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Originally posted by 0451lym at 2007-4-20 09:08:
FOR %%a IN (A: C:) DO IF EXIST SET ud=%%a

This is wrong here!
If you're checking the boot drive letter, I suggest using the volume label to determine it, that is, give your IMG a fixed volume label!

Or use CD>%TEMP%\BOOTDRV.INI ...


Looks like it's for USB booting. If so, you can also put a marker file there.
Or do it like OneKey Ghost, and after booting run
vol >x:\vol.txt
Then use the line below to determine it
type vol.txt|find /i "drive C"
Windows 一键还原
http://www.yjhy.com
Floor 8 Posted 2007-04-20 09:56 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Originally posted by lianjiang2004 at 2007-4-20 08:57:
The problem is that your cd\ is before the extraction.

cd\ returns to the root directory, I should still continue extracting, right! Even without CD\, the problem is still there!
Originally posted by lianjiang2004 at 2007-4-20 08:58:
del >nul
???
This line isn't right either, is it?

It should be del gho.zip

Originally posted by 0451lym at 2007-4-20 09:08:
FOR %%a IN (A: C:) DO IF EXIST SET ud=%%a
This is wrong here!
If you're checking the boot drive letter, I suggest using the volume label to determine it, that is, give your IMG a fixed volume label!

Or use CD>%TEMP%\BOOTDRV.INI ...

Right now the problem is that it can work while in %ud% (that is, the USB boot directory)! After switching to %RAMDRIVE%, the PATH setting from the original AUTOEXEC becomes invalid! I had always used it this way before! It's only after trying MINITO and changing CONFIG.SYS a bit that now once I enter %RAMDRIVE% the original PATH no longer works, but when I go back to the USB drive it works again.
Could it be a COMMAND problem?
Floor 9 Posted 2007-04-20 10:12 ·  中国 黑龙江 哈尔滨 电信
高级用户
★★★
Credits 760
Posts 357
Joined 2005-10-10 22:33
20-year member
UID 43332
Status Offline
FOR %%a IN (A: C:) DO IF EXIST SET ud=%%a
It should be like this:
FOR %%a IN (A: C:) DO IF EXIST %%a SET ud=%%a

But this result will always be %UB%=="C:"
Floor 10 Posted 2007-04-20 10:16 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Originally posted by 0451lym at 2007-4-20 10:12:
FOR %%a IN (A: C:) DO IF EXIST SET ud=%%a
It should be like this:
FOR %%a IN (A: C:) DO IF EXIST %%a SET ud=%%a

But this result will always be %UB%=="C:"

Thanks. But the root problem still hasn't been solved! So frustrating! I'll post CONFIG.SYS, take a look!
dos=high,umb,auto
device=\DOS\himem.sys /testmem:off
device=\dos\UMBPCI.SYS /I=D800-EFFF
device=\dos\jemm386.exe i=b000-b7ff noems
SHELL=\DOS\COMMAND.COM /P /F /E:4096
FCBSHIGH=4,0
FILESHIGH=30
BUFFERSHIGH=80,0
STACKSHIGH=9,256
LASTDRIVEHIGH=Z
Floor 11 Posted 2007-04-20 10:23 ·  中国 黑龙江 哈尔滨 电信
高级用户
★★★
Credits 760
Posts 357
Joined 2005-10-10 22:33
20-year member
UID 43332
Status Offline
I can't see any problem!
I suggest pressing CTRL+F8 when entering DOS, and going through it step by step to see where the error is!
Then use SET to see which variable is wrong!
Floor 12 Posted 2007-04-20 12:36 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Originally posted by 0451lym at 2007-4-20 10:23:
I can't see any problem!
I suggest pressing CTRL+F8 when entering DOS, and going through it step by step to see where the error is!
Then use SET to see which variable is wrong!

DOS boots normally! And AUTOEXEC executes smoothly too; including the initial PATH=%UD% working, otherwise MENU.BAT couldn't possibly get as far as CD\! The MENU.BAT called from AUTOEXEC stops at cd\ and reports Batch file missing
If I manually extract it and then enter the %RAMDRIVE%gho directory to execute GHO.BAT, then because the PATH=%UD%;%UD%\DOS set earlier in AUTOEXEC is no longer valid at that time, it causes GHO.BAT in %RAMDRIVE%gho to fail to run, and it even hangs!!! I don't know whether it could be a file-related cause!
(And when I go back from %RAMDRIVE% to %UD%, PATH=%UD%;%UD%\DOS becomes effective again!)

[ Last edited by terse on 2007-4-20 at 12:38 PM ]
Floor 13 Posted 2007-04-20 12:45 ·  中国 黑龙江 哈尔滨 电信
高级用户
★★★
Credits 760
Posts 357
Joined 2005-10-10 22:33
20-year member
UID 43332
Status Offline
I don't know if this is right either, but see whether this line is what causes the batch file missing message:
PATH=%PATH%;%RAMDRIVE%gho\;

Variables do have a certain length!
If it isn't a problem with the batch command itself, then consider it here.

[ Last edited by 0451lym on 2007-4-20 at 12:46 PM ]
Floor 14 Posted 2007-04-20 22:41 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Originally posted by 0451lym at 2007-4-20 12:45:
I don't know if this is right either, but see whether this line is what causes the batch file missing message:
PATH=%PATH%;%RAMDRIVE%gho\;

Variables do have a certain length!
If it isn't a problem with the batch command itself, then consider it here ...

The problem is here:
FOR %%a IN (A: C:) DO IF EXIST %%a SET ud=%%a

%ud% is empty. Why?
Floor 15 Posted 2007-04-20 22:49 ·  中国 江苏 苏州 联通
中级用户
★★
我是DOS学者
Credits 367
Posts 180
Joined 2006-05-14 10:53
20-year member
UID 55507
Gender Male
From 重庆
Status Offline
Can A: C: be checked with if exist??

I don't think so. You can define a file here yourself to check, like A:\test.log c:\test.log. That should be fine...
Forum Jump: