Jump to content

searching for CDROM


WotC

Recommended Posts

Hi!

Sorry if this was covered already, but the search didn't work for me. Here's my problem: i'm searching for cdrom drives using the common:

for %%i 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 %%i:\whatever.ico set cdrom=%%i:\

This worked pretty fine - till i got a card reader. Now i get an error box all the time windows searches for the cdrom drive :-(. is there any known method to circumvent this annoying popup?

Error-Message-Title: Windows - No Disk

Message-Text: There is no disk in the drive. Please insert a disk into drive.

Cancel / Try again / Continue

Any hints are welcome...

Link to comment
Share on other sites


Try a VBS script

This script will check for all CD or DVD drives if there a disk in the drive then it produce a message box to confirm a disk in the drive. If there is no disk in the drive another message box is produced that say the drive is empty.

Dim Drv, Fso, StrDrv
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives

For Each StrDrv In Drv
If StrDrv.DriveType = 4 Then
If StrDrv.IsReady = True Then
MsgBox "This CD or DVD drive has a disk in it : " & StrDrv.DriveLetter, 0 + 32,"Disk In Drive"
Else
MsgBox "This CD or DVD drive has no disk in it : " & StrDrv.DriveLetter, 0 + 32,"Empty Drive"
End If
End If
Next

This one will check for a specific file on any CD or DVD drive, when the check file is found it will produce a message box that say This is a XP CD then it will quit the script.

Change this color in the script to suit your needs.

If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then

Dim Drv, Fso, StrDrv
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives

For Each StrDrv In Drv
If StrDrv.DriveType = 4 Then
If StrDrv.IsReady = True Then
If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
MsgBox "This is a XP CD : " & StrDrv.DriveLetter, 0 + 32,"Confirm XP CD"
Exit For
Else
MsgBox "This is not a XP CD : " & StrDrv.DriveLetter, 0 + 32,"Missing XP CD"
End If
End If
End If
Next

Link to comment
Share on other sites

This worked pretty fine - till i got a card reader. Now i get an error box all the time windows searches for the cdrom drive :-(. is there any known method to circumvent this annoying popup?

Error-Message-Title: Windows - No Disk

Message-Text: There is no disk in the drive. Please insert a disk into drive.

Cancel / Try again / Continue

Any hints are welcome...

With the little info given, here is my assumption...

Seems like Windows Setup is possibly recognizing you Card Reader as a CDRom, which steals the letter used by the Windows Setup CD. Or it is disrupting the drivers of the CDRom which in effect leaves Windows Setup lost as the CD is not seen anymore. Adding the drivers for your Card Reader during textmode setup through the use of $OEM$ method may help, else perhaps you may need to leave the Card Reader disconnected during Windows Setup.

Link to comment
Share on other sites

@gunsmokingman

it produce a message box to confirm a disk in the drive
But i dont want to click butons during setup , is there no other way?

@MHz

perhaps you may need to leave the Card Reader disconnected during Windows Setup.

This is what im doing , and thats the best solution till now.

Edited by muiz
Link to comment
Share on other sites

it produce a message box to confirm a disk in the drive

But i dont want to click butons during setup , is there no other way?

What do you refering to, muiz ?

Link to comment
Share on other sites

Here the same script with out the message boxes, you will have to edit the file it checks for to suit your needs.

Dim Drv, Fso, StrDrv
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives

For Each StrDrv In Drv
If StrDrv.DriveType = 4 Then
If StrDrv.IsReady = True Then
If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE

Exit For
End If
End If
End If
Next

This was a template nothing more but then I assume most people would know that.

muiz Posted Today, 03:18 AM

@gunsmokingman

QUOTE

it produce a message box to confirm a disk in the drive

But i dont want to click butons during setup , is there no other way?

@MHz

QUOTE

perhaps you may need to leave the Card Reader disconnected during Windows Setup.

This is what im doing , and thats the best solution till now.

Link to comment
Share on other sites

The script will detect only CD or DVD drives I was only giving a alternative to this

for %%i 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 %%i:\whatever.ico set cdrom=%%i:\

Since the vbs script will only detect CD or DVD drives it should avoid the push button problem with the card reader, as to how he was using the above or when he was using it I do not know.

If you post what you have and are trying to do, I will try and help you fix the problem.

Link to comment
Share on other sites

@MHz: Sorry for the little info given. I was to busy. What i am doing is installing applications using WPI. whenever an application was installed i call a *.cmd file where start menu adjustments are made ar files like *.inis are copied to the %programfiles%\APP_whatever path. therefore i need to check where my install DVD is (e.g. which drive letter it has). i could do this just once at the beginning (did this originally) but then i though maybe i want to install additional programs later on, thats why i splitted my "one-file-cleanup" into several files.

The windows setup cd is NOT lost - just this annoying popups (yes, because windows is so stupid and thinks i got a new cdrom drive...). i think adding drivers is not of any help because windows recognizes it (USB device, if i put in a card i can access it immediately). so disconnecting the reader is the only way obviously (or go back to my "single-file-cleanup" - **** - i hate this :-(.

but thanks for your advice...

@gunsmokingman&muiz:

But i dont want to click buttons during setup , is there no other way? :D

@gunsmokingman: i'll check your script, thanks - just one question (if you are faster anserweing it than i am trying it :-)):

If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE
Exit For

i can put my xcopy blablabla.... here? with or without cmd /c ?

THANKS

edit: hmm, using the script and adding a "whatever.cmd" to be called doesnt do anything at all?! what am i doing wrong?

Edited by WotC
Link to comment
Share on other sites

@MHz: Sorry for the little info given. I was to busy. What i am doing is installing applications using WPI. whenever an application was installed i call a *.cmd file where start menu adjustments are made ar files like *.inis are copied to the %programfiles%\APP_whatever path. therefore i need to check where my install DVD is (e.g. which drive letter it has). i could do this just once at the beginning (did this originally) but then i though maybe i want to install additional programs later on, thats why i splitted my "one-file-cleanup" into several files.

The windows setup cd is NOT lost - just this annoying popups (yes, because windows is so stupid and thinks i got a new cdrom drive...). i think adding drivers is not of any help because windows recognizes it (USB device, if i put in a card i can access it immediately). so disconnecting the reader is the only way obviously (or go back to my "single-file-cleanup" - **** - i hate this :-(.

but thanks for your advice...

@gunsmokingman&muiz:

But i dont want to click buttons during setup , is there no other way? :D

@gunsmokingman: i'll check your script, thanks - just one question (if you are faster anserweing it than i am trying it :-)):

If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE
Exit For

i can put my xcopy blablabla.... here? with or without cmd /c ?

THANKS

edit: hmm, using the script and adding a "whatever.cmd" to be called doesnt do anything at all?! what am i doing wrong?

You would need to make a new Object

Here a re-edit script for you, this script will run only if a XP CD in the drive is XP SP2

Saves this as THE_NAME_YOU_WANT.vbs

I have added a new object to this it called Act, this script assumes the batch file is in the same location as the vbs script. If you have a full path to the Batch it will still work EG : H:\Folder\YOUR_CMD_FILE_NAME.cmd would work where PLACE_CMD_NAME_HERE
Dim Act, Drv, Fso, StrDrv
Set Act = CreateObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives

For Each StrDrv In Drv
If StrDrv.DriveType = 4 Then
If StrDrv.IsReady = True Then
If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE
Act.Run("PLACE_CMD_NAME_HERE"),1,True
Exit For
End If
End If
End If
Next

This is a demo VBS using %Comspec% and doing a action, this will only run if a XP CD is in the drive and must be SP2.

Save As THE_NAME_YOU_WANT.vbs

Dim Act, Drv, Fso, StrDrv
Set Act = CreateObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives

For Each StrDrv In Drv
If StrDrv.DriveType = 4 Then
If StrDrv.IsReady = True Then
If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE
Act.Run("%Comspec% /C @Echo Off && CLS && Mode 55,5 " &_
"&& Color 3f && Echo. && Echo %ComputerName% && set /p = %UserName% Press Key To Close"),1,True
Exit For
End If
End If
End If
Next

You can change the check file name if you like to suit your needs

Change this color text to suit your needs,

this is the files it checks for on a CD or DVD drive.

If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then

Link to comment
Share on other sites

hey hey hey... getting closer - thanks. one more question:

If StrDrv.DriveType = 4 Then

this checks only "real" cdrom drives, doesn't it? how can i change that to include fixed drives, too? i want to "override" the cdrom path with a harddrive path whenever a certain file is present. using that "trick" i don't need to burn a dvd every time im installing my system and nevertheless have the latest software installed. i would do two subsequent for loops for that purpose (because on my install dvd the files im'm checking for are located within e.g. xxx\yyy and on a fixed drive the path would be \unattended\xxx\yyy). would that work?

Link to comment
Share on other sites

I have added another loop for the harddrive, just fill in the path that you need.

Dim Act, Drv, Fso, StrDrv
Set Act = CreateObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives

For Each StrDrv In Drv
If StrDrv.DriveType = 4 Then
If StrDrv.IsReady = True Then
If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE
Act.Run("%Comspec% /C @Echo Off && CLS && Mode 55,5 " &_
"&& Color 3f && Echo. && Echo %ComputerName% && set /p = %UserName% Press Key To Close"),1,True
Exit For
End If
End If
End If
Next
'''' CHECK FOR HARDDRIVE BELOW HERE ADD CORRECT PATH FOR FILE EXISTS
For Each StrDrv In Drv
If StrDrv.DriveType = 2 Then
If Fso.FileExists(StrDrv.DriveLetter & ":\win51ip.SP2") Then
'''' PLACE_SCRIPT_HERE_THAT_YOU_NEED_BELOW_HERE
Act.Run("%Comspec% /C @Echo Off && CLS && Mode 55,5 " &_
"&& Color 3f && Echo. && Echo %ComputerName% && set /p = %UserName% Press Key To Close"),1,True
Exit For
End If
End If
Next

In the above you could also check for a folder exists also

EG If Fso.FolderExists(StrDrv.DriveLetter & ":\FOLDER_NAME_HERE") Then

Edited by gunsmokingman
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...