Jump to content

New methods to get the cd-rom letter


Recommended Posts

Method 1

Create a file called cdrom.cmd, and put it in the $OEM$ directory of your unattended cd. In cdrom.cmd put:

echo set cdrom=%cd:~0,2%>>%systemdrive%\autoexec.bat

Save the file. Now add:

"cdrom.cmd"

to your cmdlines.txt file.

This method will return your CD-ROM drive as system variable %cdrom% in the format of “X:”

Note: The system variable %cdrom% will not be available until the computer restarts. If you are only doing it for RunOnceEx, it should work just fine.

Method 2

Get setx.exe from your XP cd under “X:\support\tools\support.cab”, and put it in “$OEM\$$\System32” folder. In your cmdlines.txt, add:

"setx cdrom -k HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\SourcePath"

This method will return your CD-ROM drive as system variable %cdrom% in the format of “X:\”

Final note: These methods will only work if you install windows from a CD.

Link to comment
Share on other sites


Guest zippy

FOR /F "skip=4 tokens=3" %I IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "SourcePath"') DO (
 SETX CDFullPath "%~I"
 SETX CDDrive "%~dI"
 SETX CDPath "%~pI"
)

found in someone else's post here...long time ago.

Link to comment
Share on other sites

Why do that when just plain %cd% works  :)

His method works on either the hd, or cdrom, where the %CD% only works on the cdrom.

If it is only effective on the cdrom, then you might as well use %~d0 in your script.

Link to comment
Share on other sites

Why do that when just plain %cd% works  :rolleyes:

His method works on either the hd, or cdrom, where the %CD% only works on the cdrom.

If it is only effective on the cdrom, then you might as well use %~d0 in your script.

%cd% means current directory!

It will give the path to where ever you call it from.

It is universal.

Please try things before saying it won't work as people browse this forum and take information as fact. :)

Link to comment
Share on other sites

Why do that when just plain %cd% works  :rolleyes:

His method works on either the hd, or cdrom, where the %CD% only works on the cdrom.

If it is only effective on the cdrom, then you might as well use %~d0 in your script.

%cd% means current directory!

It will give the path to where ever you call it from.

It is universal.

Please try things before saying it won't work as people browse this forum and take information as fact. :)

So let me get this straight, %CD% gives you the current directory from where you call it. Which means something will have to call this script from the cdrom (cmdlines).

zippy's method can be called from the cdrom (cmdlines), or hd (runonce).

Sure you can put the cmd anywhere you want, but if you are calling it from cmdlines, what is the point of having the cmd on the hd?

If you are going to be calling it from the cdrom, then leave the cmd file on the cdrom, and you can use %~d0. If you want the path, %~dp0.

Also I didn't say it wouldn't work. Just trying to understand your logic.

Link to comment
Share on other sites

edmoncu -

So with DetectCD2 I would just add some thing like so to the cmdlines.txt:

[COMMANDS]
"CMD DetectCD2 /C"

Then %cdrom1% and %cdrom2% values would be useable for the likes of runonceEX...so I could then use some thing like:

REG ADD %KEY%\015 /V 1 /D "%CDROM1%\Software\AdobeReader\AR6.msi /qn" /f

Or am I missing some thing?

Also where should it be placed?

$OEM$ or $OEM$\$$\SYSTEM32 hehe or else where?

Link to comment
Share on other sites

[bM]Crusher -

Now I'm taking a bit of a stab in the dark here...but I'm guessing that fuctions the same as:

cmdow @ /HID
@echo off
set tagfile=\WIN51

IF EXIST C:%tagfile% SET CDDRIVE=C:
IF EXIST D:%tagfile% SET CDDRIVE=D:
IF EXIST E:%tagfile% SET CDDRIVE=E:
...

In which case I suffer from a issue and thats hdd's (raid) showing up post the execution of that code...which then bumps the cdrom to a different value...but its not reflected in the code.

Tho I do run that code from RunOnceEX.cmd....maybe I should have it placed else where...well thanks for you time thus far...and any working answers are more than welcome. :)

Link to comment
Share on other sites

So let me get this straight, %CD% gives you the current directory from where you call it. Which means something will have to call this script from the cdrom (cmdlines).

zippy's method can be called from the cdrom (cmdlines), or hd (runonce).

Sure you can put the cmd anywhere you want, but if you are calling it from cmdlines, what is the point of having the cmd on the hd?

If you are going to be calling it from the cdrom, then leave the cmd file on the cdrom, and you can use %~d0. If you want the path, %~dp0.

Also I didn't say it wouldn't work. Just trying to understand your logic.

Yes you call it from cmdlines but it injects it into the registry at the 13min mark.

So when run once runs (from the hard drive) it has the letter from the cd cause it originally called from cmdlines.

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...