Jump to content

Recommended Posts

Posted

Hi,

Is there a command like %systemdrive% but for "Cd-rom drive"?

In one of my batch files I hard-coded D: to specify my CD-Rom drive but I would rather not since other systems will not have D: as their Cd-Rom drive.

Is there a way to tell the system to look at the CD-ROM Drive and not just a hard-coded drive letter?

thanks


Posted

Inside a batch file you can use the %CD% variable for the current working directory. The %CD% variable isnt sugesting CDROM, it's short for Current Directory.

The %CDROM% variable works only during the installation phase, if I recall correctly.

The %CD% variable only exists in XP and above I believe. What I use in my batch files is the %~dp0 command. Like this:

SET MAINDIR=%~dp0

ECHO %MAINDIR%

To launch a file in the same directory as the batch file use:

%~dp0SETUP.EXE

You can also call a file in a relative subdirectory:

%~dp0FIREFOX\SETUP.EXE

Notice the lack of a backslash after %~dp0. %~dp0\SETUP.EXE is incorrect because %~dp0 includes the trailing backslash (although if you put it in on accident it still seems to work).

Posted

This (working on XP Pro) will create variable strCdRom with drive letter... If you have more cdrom drives, I can create filter for cdrom name/media loaded

for /f "usebackq delims== tokens=1,2" %i IN (`wmic cdrom get drive /value`) DO set strCdRom=%j

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