ispy Posted July 27, 2007 Share Posted July 27, 2007 Hello All, Go easy here, cus I am new to this forum site & well a bit of a lamer! Incidentally I am working off an XPPRO OS!I was wondering whether there is a resonably easy way in NT command prompt of being able to identify which drive letter is being used for your CDROM/WRITER (or DVD Drive for that matter) then designating that drive letter as a variable to instruct the batch file looking in that drive to extract say certain files from an XP/2K/2K3/NT OS install CD. Or if someone knows of a small CMD Util that will do this, all the better? Preferably it will need to be able to work off NT/2K/2K3/XP systems. Not asking for much am I, LOL!I have tried on various forums including this one & have not found one that will work for me as yet!Regards,ispy Link to comment Share on other sites More sharing options...
IcemanND Posted July 27, 2007 Share Posted July 27, 2007 Welcome to the forum.First instruction Search, Search, Search.Buit for starters:http://www.msfn.org/board/index.php?showto...10798&view=http://www.msfn.org/board/lofiversion/index.php/t100262.html Link to comment Share on other sites More sharing options...
benners Posted July 27, 2007 Share Posted July 27, 2007 copy the code below and save it as a cmd file. when run the console will display various things like drive, path name etc if you use %~d0 in your batch file it should get the CD-Rom drive.@echo offecho This script will show several (hopefully) interresting things of theecho variable %%0echo.echo Command executed (%%0) : %0echo Directories (%%~p0): %~p0echo Drive (%%~d0): %~d0echo Filename (no ext.) (%%~n0): %~n0echo Extension (%%~x0): %~x0echo Full path + filename (%%~f0): %~f0echo Modification time (file) (%%~t0): %~t0echo Filesize (%%~t0): %~t0pause Link to comment Share on other sites More sharing options...
ispy Posted July 27, 2007 Author Share Posted July 27, 2007 Thanx IcemanND & Benners for your prompt replies,Firstly, IcemanND I did SEARCH SEARCH but regretably missed the third "SEARCH" on the list LOL! Are there any instructions on how to use your little gizmoes as I have run the .EXE files then opened CMD, typed set to list the variables & no variables listed indicate a CDROM drive as far as I can see. Can you let me know how it works & maybe a couple of practical examples to grasp how it works. I have grabbed DETECTCD2.EXE DETECTCD.EXE & DETECTDRIVE.EXE which one best suits the scenario listed in the 1st posting please?Secondly, Benners I have made the .CMD file & as you suggest it does indeed report the info that you suggest, then you go on to say that if within a batch file I use %~d0 I will obtain the CDROM Drive letter. Will this be a variable or will it find the actual drive letter "if that is the right term to use". Could you provide a simple working example as a guide please?Will these two alternatives work within 2K/2K3 & XP?Regards,ispy Link to comment Share on other sites More sharing options...
IcemanND Posted July 27, 2007 Share Posted July 27, 2007 If you run DetectCD or DetectDrive you need to run them before you open a cmd window to be able to access them in the cmd window as they write the variables directly to the registry.for %%a in (C 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 %%a:\WIN51 set CDROM=%%a:this will set CDROM to the drive that WIN51 was first found on.to use Brenners method you would need to use the SET command and set a variable to the desired variable in his script. Link to comment Share on other sites More sharing options...
benners Posted July 28, 2007 Share Posted July 28, 2007 Thanx IcemanND & Benners for your prompt replies,Firstly, IcemanND I did SEARCH SEARCH but regretably missed the third "SEARCH" on the list LOL! Are there any instructions on how to use your little gizmoes as I have run the .EXE files then opened CMD, typed set to list the variables & no variables listed indicate a CDROM drive as far as I can see. Can you let me know how it works & maybe a couple of practical examples to grasp how it works. I have grabbed DETECTCD2.EXE DETECTCD.EXE & DETECTDRIVE.EXE which one best suits the scenario listed in the 1st posting please?Secondly, Benners I have made the .CMD file & as you suggest it does indeed report the info that you suggest, then you go on to say that if within a batch file I use %~d0 I will obtain the CDROM Drive letter. Will this be a variable or will it find the actual drive letter "if that is the right term to use". Could you provide a simple working example as a guide please?Will these two alternatives work within 2K/2K3 & XP?Regards,ispyThe %~d0 will return the drive letter i.e E: %~d0 is already a variable. you can the add this to the path to the program you want to run. I don't know what it is you are trying to do but for example if you wanted to run an exe that was in the root of the CD you would have %~d0\filetorun.exe this would give you E:\filetorun.exe assuming the CD drive was E: Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted July 28, 2007 Share Posted July 28, 2007 The %~d0 will simply display the current drive, which may not be the CDROM.Here is a batch file that will find all CDROMs and provide the environment variable of CD1, CD2, etc.:@echo off:::::::::::::::::::::::::::: Title: GetCD.cmd :::: Author: Scr1ptW1zard :::: Date: 07/27/2007 ::::::::::::::::::::::::::::echo list vol>.\listvol.dpsetlocal enabledelayedexpansionset CD=for /f "tokens=3" %%a in ('diskpart /s .\listvol.dp^|find /i "-ROM"') do ( set /a count=!count! + 1 set CD!count!=%%a:)::::::::::::::::::::::: Display CDROMs ::::::::::::::::::::::::: NOTE::: Variables begin with "CD" followed by a number.:: The number begins with 1 and increments to the total number of CDROMsset cd:::::::::::::::::::::::::::::: Use CD# variables here ::::::::::::::::::::::::::::::endlocalHope this helps. Link to comment Share on other sites More sharing options...
benners Posted July 28, 2007 Share Posted July 28, 2007 The %~d0 will simply display the current drive, which may not be the CDROM.Yep, should have stated, the batch file needs to be run from the CD, but assumed that's what the OP had in mind Link to comment Share on other sites More sharing options...
ispy Posted July 28, 2007 Author Share Posted July 28, 2007 Well Guys I am Blown away,You certainly know your stuff on this forum, not that is a great recommendation coming from Lamer like Me, but it is a response of appreciation from ME - non the less!The Variable within the Set CMD reports CDROM1=F: & CDROM2=G: along with other set variables. All I need to do now is instruct the user to insert the OS Install CD, allow it to spin up or use Horst Schaeffers dready as a check maybe, the variable with if exist will locate the inserted OS CD (With a files Check) then from a Wbat menu (front end) copy the files to a folder on my HDD to compile a bootable recovery console CD, the fileset is obtainable from within the Bootdisk\ folder on the OS Install CD.I have acquired the Win2K Gold .IMG files (OEM) which reputedly by-passes any XP Logon password so this could be an option also.Some could say why not use BartsPE or UBCD well yes but this is a quick small bootdisk varient that would replace the floppy Boot disk for the Recovery console as many PC users do not have a floppy drive anymore or floppies take an age to load. Batch files could also be written to try to repair the reg or copy files etc to removeable media from RConsole etc.Barts & UBCD require quite a bit of setting upThis essentially is background info for this posting, thanks guys!Regards,ispy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now