Jump to content

How can I change the CD-ROM drive letter...


Recommended Posts

Hey guys,

does anyone know how to change the CD-ROM drive letter before my applications will install from the CD?

I'm using the following code in my "RunOnceEx.cmd" to install all my stuff from the CD/DVD:

FOR %%i 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 IF EXIST %%i:\CD.txt SET CDROM=%%i:

The problem is, that the setup is always using the letter D: for the CD-ROM drive but I'd like to assign this letter to my DATA-Partition.

Link to comment
Share on other sites


I have lines in my runonceex that call a text document with arguments for diskpart (I assign Z as D is used for my data partition as well). There are probably easier ways, but this way I know exactly when it happens and can easily adjust.

REG ADD %REGKEY%\022 /VE /D "changing drive letter" /f

REG ADD %REGKEY%\022 /V 22 /D "diskpart /s %path%\chgdrvltr.txt" /f

[contents of chgdrvltr.txt]

select volume 0

assign letter=z noerr

exit

Link to comment
Share on other sites

  • 2 weeks later...

Jaclaz thats is very nice. If there are multiple fixed CD/DVD drives is there a way prior to load to determine in which order your script will name them.

Im thinking when I have a 2 DVD load (Im at like 3.6GB right now so its coming), running your solution at T-13 from cmdlines.cmd would allow me to access data from a DVD in another tray during the runonce portion if I knew what letter it was getting, further eliminating user tasks.)

Or - If I throttle my users to a max of 2 cd/dvd drives, does a second optical drive assume the same volume every time so I could add a second line to the diskpart arguments.

All apologies for hijacking your thread, I blame Jaclaz for showing how the cool kids do it. B)

Link to comment
Share on other sites

just an idea i currently had while reading what you want. why don't you specify the files you have on disc 2 in the DOSNET.INF / LAYOUT.INF where you can specify more discs easily? Never tried that since i use my unattended only in my lan, so i only have the RunOnceEx.cmd called by cmdlines.txt on my disc, everything else (including RunOnceEx1.cmd which is called by RunOnceEx.cmd) is on the network. i create the required network drive with

%SYSTEMROOT%\system32\net.exe use T: \\COMPUTERNAME\\SHARENAME PASSWORD /user:COMPUTERNAME\USERNAME

then i can directly run everything without questions from T:\ - be sure you use this command before you run any command from T:\ otherwise you may get errors.

I never tried that too but another idea: can you access files by using the hardware string like \\multi(0)disk(0)rdisk(0)partition(1)\WINDOWS\System32\some.dll? I'm thinking about installing the applications from USB stick, windows itself from CD.

Edited by an3k
Link to comment
Share on other sites

Well if you run diskpart list volume, with one CD/DVD ROM it is always detected as Volume 0, I guess that second CD/DVD ROM will be next. :unsure:

You can read which volumes # are given to a CD device and then "call" the appropriate "couples" of:

select volume #

assign letter=x noerr

exit

Here is just an example - just to verify that CD drives are detected correctly, you will need to add yourself the "logic" to assign drive letters.

(check also the updated example in the linked thread for ideas on how to find FREE drive letters)


@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SETLOCAL ENABLEEXTENSIONS

FOR /F "tokens=1 delims=[]" %%A in ('FIND /N "::THIS IS START OF DISKPART BATCH COMMANDS::" "%~dpnx0"') DO SET More_offset=%%A

FOR /F "tokens=*" %%A IN ('ECHO list volume^|diskpart^|FIND "-ROM"') DO (
SET LINE=%%A
SET token1=!LINE:~7,2!
SET token1=!token1: =!
REM IF !token1! lss 10 SET token1=0!token1!
SET token2=!LINE:~13,1!
SET CD_Vol#!token1!=!token2!
SET CD_Vols=!CD_Vols! !token2!
)

SET CD_
PAUSE

FOR %%A IN (%CD_Vols%) DO (
SET /A DP_Line#=%%A*3+%More_offset%
FOR /F "tokens=* delims=" %%B IN ('MORE +!DP_Line#! "%~dpnx0"^|diskpart.exe^|FIND "*"') DO (
ECHO Active Volume is %%B
)
)

GOTO :EOF

::THIS IS START OF DISKPART BATCH COMMANDS::
select volume 0
list volume
EXIT
select volume 1
list volume
EXIT
select volume 2
list volume
EXIT

When you blame others, you give up your power to change.
Men are only clever at shifting blame from their own shoulders to those of others.

:whistle:

jaclaz

Link to comment
Share on other sites

It is looking like I get volume 0 and volume 1 consistently when they are on the same cable, but have yet to introduce other devices.

-----------------------

Both fine quotes, though they lose something when applied to veiled praise.

(wow from roman history to the power of positive thinking, quite diverse)

I think this one would be more abrasive to those who attempt to genuinely place blame, and as a bonus he was italian too.

The sad souls of those who lived without blame and without praise - Durante degli Alighieri (Dante)
.
Link to comment
Share on other sites

Both fine quotes, though they lose something when applied to veiled praise.

Yep :), but:

Praise me not too much,

Nor blame me, for thou speakest to the Greeks

Who know me.

(and NO, that is not Homer Simpson) ;)

jaclaz

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...