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
^ 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
^ 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
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)
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
YF
Ted Davis <tda...@gearbox.maem.umr.edu> wrote in message news:<q5iduugl334vu46h7...@4ax.com>...
> 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)
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
> 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
TC
Phil Robyn <zipp...@uclink.berkeley.edu> wrote in message news:<3DE9BDD3...@uclink.berkeley.edu>...
> 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.
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
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.
: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/
"Todd Vargo" <todd...@nccw.net> wrote in message news:<ase020$p6hkj$1...@ID-25025.news.dfncis.de>...
Sounds like you actually *want* to run out of time. Cheer up.
/Al
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,