Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Environment variable for CD-ROM drive during unatended setup?

392 views
Skip to first unread message

Yer Fooked

unread,
Nov 28, 2002, 2:33:04 PM11/28/02
to
Howdy -

I am building an unattended Windows XP setup CD using a
\i386\winnt.sif file. The problem is, on some systems, the CD is
mounted as D:, but on others it is E: or even F:.

I need to run some commands off of the CD from the winnt.sif file. If
I specify D:\foo\bar.exe then it fails on those machines where the CD
is not mounted as D:.

Does anyone know of an environment variable or any other method I can
use to call the command? Something like %CDROM%\foo\bar.exe - similar
to %SYSTEMDRIVE% or %SYSTEMROOT%.

Thanks
YF

Frank

unread,
Nov 28, 2002, 4:19:36 PM11/28/02
to
Yer Fooked <60ee3f01.0211...@posting.google.com>...

^ I need to run some commands off of the CD from the winnt.sif file. If
^ I specify D:\foo\bar.exe then it fails on those machines where the CD
^ is not mounted as D:.

There are a few unconventional methods for obtaining the drive letter of a
CDROM drive but for your application they may be unnecessary and a test for
the specific file may be sufficient:

Set "Drives=D E F G H I J K L M N O P Q R S T U V W X Y Z"
Set "TestFile=\foo\bar.exe"
Set "CDROM="
For %%d in (%Drives%) Do IF EXIST %%d:%TestFile% Set "CDROM=%%d"
If NOT DEFINED CDROM Goto :Err_NoDrive
%CDROM%\foo\bar.exe

Frank

Frank

unread,
Nov 28, 2002, 4:31:38 PM11/28/02
to
Frank <01c29724$00ae6080$0125250a@saltumzbbiyrbteg>...

^ For %%d in (%Drives%) Do IF EXIST %%d:%TestFile% Set "CDROM=%%d"

Oops again. There should be a colon in that SET statement:

For %%d in (%Drives%) Do IF EXIST %%d:%TestFile% Set "CDROM=%%d:"

Frank

Ted Davis

unread,
Nov 28, 2002, 8:55:38 PM11/28/02
to
On 28 Nov 2002 11:33:04 -0800, yerf...@hotmail.com (Yer Fooked)
wrote:

If you boot from the CD, and don't change the default drive, then you
don't need to know what it is: \foo\bar.exe should be enough (file
bar.exe in the foo directory off the root of the default drive).


T.E.D. (tda...@gearbox.maem.umr.edu - e-mail must contain "T.E.D." or my .sig in the body)

zeke03

unread,
Nov 30, 2002, 6:03:18 AM11/30/02
to

if you want to find the CD-ROM letter, to execute a bat without any paramaters
for exemple, there are different way to find it :

for NT, the letter is on the registry
for xp, 2000 it's different....

if you want, i can send you some exemple next week
--
Ce message a ete poste via la plateforme Web club-Internet.fr
This message has been posted by the Web platform club-Internet.fr

http://forums.club-internet.fr/

Yer Fooked

unread,
Nov 30, 2002, 4:50:59 PM11/30/02
to
Nope, that didn't work - it looked on c:\ instead of the CD-ROM drive.

YF

Ted Davis <tda...@gearbox.maem.umr.edu> wrote in message news:<q5iduugl334vu46h7...@4ax.com>...

Todd Vargo

unread,
Nov 30, 2002, 10:41:23 PM11/30/02
to

"Yer Fooked" <yerf...@hotmail.com> wrote

> Nope, that didn't work - it looked on c:\ instead of the CD-ROM drive.

In other words, you provided the wrong information and/or asked the wrong
question. This sounds to me like you created the boot CD to emulate a hard
drive (opposed to emulating a floppy).

When emulating a HD, C: would be the drive letter of the bootable region of
the CD. To install the OS correctly, you need to emulate a floppy so that
your not interfering with the drive lettering process when the setup program
is run (assuming only one floppy drive is installed).

For practical reasons, I recommend you create an EBD from either Win98 or
WinME and use that as your boot model. If you do that, the following will
detect which drive your CD is in.

:: FIND_CD.BAT
@echo off
if %1'==find_cd' goto %1
::
:: All lines begin with 2 spaces. Any lines beginning in
:: the first column have wrapped from preceding line.
::
:: The only requirement of this batch is that it must be
:: able to create a temporary file in either, the location
:: the TEMP variable points to, or the current directory.
:: For boot CD's, point TEMP to a ramdrive as below.
::
if not '==%ramd%' set temp=%ramd%:\
::
::=======================================================
:: Replace FILENAME.EXT below with the name of a file on
:: the CD. For best results, don't use a common file name
:: like, setup.exe or install.exe or autorun.inf, etc.
:: that may exist on other CD's.
::
set flag=\FILENAME.EXT
::=======================================================
set cd=?
echo It's safe to delete this temporary file.>%temp%.\cd_found.no
if not exist %temp%.\cd_found.no echo Could not create temporary file.
if not exist %temp%.\cd_found.no goto end
call %0 find_cd C D E F G H I J K L M N O P Q R S T U V W X Y Z
del %temp%.\cd_found.*>nul
if ?==%cd% echo CD is not in drive, or %flag% is not on CD.
if ?==%cd% goto end
echo Drive letter of CD-ROM is %cd%
::
:: *** Put your install commands here. ***
::
goto end
:find_cd
%comspec% nul/f/c if exist %2:%flag% ren %temp%.\cd_found.no *.yes>nul
if exist %temp%.\cd_found.yes set cd=%2:
shift
if %cd%'==?' if not %2'==' goto find_cd
:end

--
Todd Vargo (body of message must contain my name to reply by email)

Phil Robyn

unread,
Dec 1, 2002, 2:44:19 AM12/1/02
to

For Win2000 and (presumably) WinXP, you could try the following:

=====begin c:\cmd\TEST\GetCDRom.cmd====================
1. @echo off
2. setlocal
3. for %%a in (d e f g h i j k l m n o p q r s t u v w x y z) do (
4. chkntfs %%a: | find "cdrom" >nul&&set CDROM=%%a:
5. )
6. if [%1]==[.] echo The CD ROM drive is %CDROM%
7. endlocal&set %~n0=%CDROM%&goto :EOF
=====end c:\cmd\TEST\GetCDRom.cmd====================

The result is returned in environment variable GetCDRom.

--
U s e ' R e p l y - T o ' a d d r e s s o r
u n z i p ' F r o m ' t o s e n d m a i l

Yer Fooked

unread,
Dec 1, 2002, 3:47:26 PM12/1/02
to
"Todd Vargo" <todd...@nccw.net> wrote in message news:<asc0e4$o7rhg$1...@ID-25025.news.dfncis.de>...

> In other words, you provided the wrong information and/or asked the wrong
> question. This sounds to me like you created the boot CD to emulate a hard
> drive (opposed to emulating a floppy).

No, you provided the wrong answer to the question (which was asked
perfectly clearly). I created the CD using NO emulation and the
bootsector ripped from a an MSDN Windows 2000 Server CD (see
http://www.bink.nu/Bootcd/ for more details). I am running commands
from within the \i386\winnt\winnt.sif file on the CD, using the
[GUIRunOnce] section. If I specify D:\FOO\BAR.EXE and the CD is in
the E: drive (i.e. the target machine has multiple drives or multiple
partitions), then my unattended install pukes.

> When emulating a HD, C: would be the drive letter of the bootable region of
> the CD. To install the OS correctly, you need to emulate a floppy so that
> your not interfering with the drive lettering process when the setup program
> is run (assuming only one floppy drive is installed).

Not when you are using the native boot sector of a Windows 2000 CD.

> For practical reasons, I recommend you create an EBD from either Win98 or
> WinME and use that as your boot model. If you do that, the following will
> detect which drive your CD is in.

No, you don't understand what I am doing. An EBD image is not the
best way to create a bootable CD to install W2K or XP from - it
requires that you format the hard drive with FAT or FAT32 first, then
run the install. If you use the boot sector from a W2K CD, you get
the "Press any key to boot from the CDROM" message and you can do the
partitioning and formatting in native W2K installation.

Hopefully this clarifies things so that you can understand what I am
doing.

YF

Yer Fooked

unread,
Dec 1, 2002, 3:49:17 PM12/1/02
to
Very cool, thanks so much. Will test it out.

TC

Phil Robyn <zipp...@uclink.berkeley.edu> wrote in message news:<3DE9BDD3...@uclink.berkeley.edu>...

Todd Vargo

unread,
Dec 1, 2002, 4:46:54 PM12/1/02
to

"Yer Fooked" <yerf...@hotmail.com> wrote:

> No, you provided the wrong answer to the question (which was asked
> perfectly clearly).

I guess your right. Some how I missed what OS was mounting the CD drives.


> Hopefully this clarifies things so that you can understand what I am
> doing.

No, but I understand what the end goal is, so I suggested a method that
works *only* if the EBD recommendation was followed. Oh well sorry if I
wasted your time.

Ritchie

unread,
Dec 2, 2002, 3:45:57 AM12/2/02
to
"Phil Robyn" <zipp...@uclink.berkeley.edu> wrote in message news:3DE9BDD3...@uclink.berkeley.edu...
> For Win2000 and (presumably) WinXP, you could try the following:

Make the above, 'for NT4 and Win2000'. The output from CHKNTFS for CD drives
under XP is different to NT4/W2K:-

CD Drive with disc -----> The type of the file system is RAW.
F: is not dirty
CD Drive without disc --> Cannot query state of drive E:

For WinXP, use FSUTIL:-

set cdrom=None
for %%a in (d e f g) do (
fsutil fsinfo drivetype %%a:|find "CD-ROM">nul&&set cdrom=%%a:
)
echo/%cdrom%

BTW, typical output of 'fsutil fsinfo drivetype' is:-

Hard drive ----------> c: - Fixed Drive
CDROM drive ---------> f: - CD-Rom
Subst drive ---------> x: - Fixed Drive
Floppy drive --------> a: - Removable Drive
Network drive -------> s: - Removable/Network Drive
Non-existent drive --> q: - No such Root Directory

--
Ritchie, MCBE
Undo address for mail


Ritchie

unread,
Dec 2, 2002, 4:22:01 AM12/2/02
to
"Yer Fooked" <yerf...@hotmail.com> wrote in message news:60ee3f01.0211...@posting.google.com...

> Howdy -
>
> I am building an unattended Windows XP setup CD using a
> \i386\winnt.sif file. The problem is, on some systems, the CD is
> mounted as D:, but on others it is E: or even F:.

In addition to the method suggested by Frank, you might also consider
using the VOL command, something like:

set MyVolume=backup02


set cdrom=None
for %%a in (d e f g) do (

vol %%a: 2>nul|find "%MyVolume%" >nul&&set cdrom=%%a:
)
echo/%cdrom%

But I'd be surprised if the %0\..\ syntax didn't work. Its used in logon
scripts to reference other programs/utils relative to the the location of
the logon script itself. I've also used it for CDs, though not unattended
O/S installs. For example, supposing MYAPP.EXE is in the same directory as
your batch, you might be able to use:-

%0\..\MYAPP.EXE

Or you might also be able to determine the drive letter using parameter
substitution:-

set ThisDrive=%~d0

See CALL/? for more info.

zeke03

unread,
Dec 3, 2002, 5:13:52 AM12/3/02
to

@echo off
echo /// Recherche de la version d'OS
ver | find "Windows NT" > NUL
IF NOT ERRORLEVEL 1 GOTO NT
ver | find "Windows 2000" > NUL
IF NOT ERRORLEVEL 1 GOTO 2000XP
ver | find "Windows XP" > NUL
IF NOT ERRORLEVEL 1 GOTO 2000XP
ECHO Desole, pour Windows NT4/2000/XP seulement ...
GOTO End


:NT
echo *-*-*-*-* Recherche du lecteur CDROM *-*-*-*-*
for %%a in (c d e f g h i j k) do (
chkntfs %%a: | find "cdrom" >nul&&set cd_rom=%%a)

echo ... La lettre du lecteur CD est : %cd_rom%
goto install


:2000XP
echo *** Serveur de type Windows 2000 ou XP ***

echo Recherche de la lettre du lecteur CD-ROM ...
REGEDIT /E %temp%\cd.txt "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"

TYPE %temp%\cd.txt | FIND "\\DosDevices\\" | FIND /V "\\DosDevices\\A:" | FIND
"=hex:5c," > %temp%\cd2.txt

for /f "tokens=3 delims=\:" %%i in (%temp%\cd2.txt) do set cd_rom=%%i

if exist %temp%\cd.txt del %temp%\cd.txt
if exist %temp%\cd2.txt del %temp%\cd2.txt
goto install

--
Use our news server 'news.foorum.com' from anywhere.
More details at: http://nnrpinfo.go.foorum.com/

Yer Fooked

unread,
Dec 8, 2002, 3:17:40 PM12/8/02
to
Nah, no waste. Sorry I was snippy - my bad. It's been a long *month*
and there's no end in site! :-(

"Todd Vargo" <todd...@nccw.net> wrote in message news:<ase020$p6hkj$1...@ID-25025.news.dfncis.de>...

Al Dunbar

unread,
Dec 8, 2002, 5:02:52 PM12/8/02
to

"Yer Fooked" <yerf...@hotmail.com> wrote in message
news:60ee3f01.02120...@posting.google.com...

> Nah, no waste. Sorry I was snippy - my bad. It's been a long *month*
> and there's no end in site! :-(

Sounds like you actually *want* to run out of time. Cheer up.

/Al

Todd Vargo

unread,
Dec 9, 2002, 12:51:03 AM12/9/02
to

"Yer Fooked" <yerf...@hotmail.com> wrote in message
news:60ee3f01.02120...@posting.google.com...
> Nah, no waste. Sorry I was snippy - my bad. It's been a long *month*
> and there's no end in site! :-(

If your still looking for a solution, have a look at the batch examples
posted. The solution is as simple as having a batch run (with find CD code)
on the first normal boot after installation. By doing this, it would be
unnecessary to place the CD letter in the .sif file (nor trying to create
variables *within* the setup process), to run additional installations.

HTH,

0 new messages