Bezalel Posted November 15, 2005 Share Posted November 15, 2005 Is there a tool I can use to determine is a CD-R drive is installed in my PC? I an making an unattended setup and only want to install CD burining software if I have a CD-R drive. Link to comment Share on other sites More sharing options...
mmarable Posted November 15, 2005 Share Posted November 15, 2005 Well, using WMI might hold some promise. According to this documentation, the "Capabilities" attribute might work. If a drive supports writing, it will show that. http://msdn.microsoft.com/library/default...._cdromdrive.aspSo, if you don't mind doing a little VBScripting or JavaScripting you could check the capabilities of any CD drives and install the buring software on any that support writing. Link to comment Share on other sites More sharing options...
gunsmokingman Posted November 15, 2005 Share Posted November 15, 2005 Here a script that will tell if it a CD-RW Check_For_CDRW.VBSOn Error Resume NextDim Act, SearchString, SearchChar, MyPosstrComputer = "."Set Act = CreateObject("Wscript.Shell")Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive") For Each objItem in colItems SearchString = objItem.Caption MyPos = Instr(1, SearchString, "RW") If MyPos = 1 Then MsgBox "This Is Not A CD-RW", 0 + 32, "Not A CD-RW" Else SearchChar = "Caption: " & objItem.Caption & vbCrLf & "Name: " & objItem.Name & vbCrLf MsgBox SearchChar, 0 + 32, "Confirm CD-RW" '''''PLACE THE SOFTWARE INSTALL PART BELOW HERE '''''PLACE QUOTE AROUND THE PATH AND SWITCHES "PATH_TO_SOFTWARE /SWITCHES" ''Act.Run(PLACE_THE_SOFTWARE_TO_INSTALL_HERE),1,True '''''END THE SOFTWARE INSTALL HERE Exit For End If NextHere is a script that checks for CD drivesDim Act,CD,FsoSet Act = CreateObject("Wscript.Shell")Set Fso = CreateObject("Scripting.FileSystemObject") Set CD = Fso.Drives For Each strCd In CD If strCd.DriveType = 4 Then Act.Popup strCd, 5,"CDROM", 0 + 32 End If Next Link to comment Share on other sites More sharing options...
Bezalel Posted November 15, 2005 Author Share Posted November 15, 2005 Thanks for both of your replies. I wrote the following script the to check for a CD-R drive but it isn't working:ReturnCode=0strComputer = "."Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colCDROMDrive = objWMIService.ExecQuery ("Select * from Win32_CDROMDrive")For each objCDROMDrive in colCDROMDrive For i = 0 to Ubound(objCDROMDrive.Capabilities)' Wscript.Echo "CDROMDrive Capabilities: " & objCDROMDrive.Capabilities(i) if objCDROMDrive.Capabilities(i) = 4 then ReturnCode = 1 NextNext'Wscript.Echo "Return Code: " & ReturnCodeWscript.Quit(ReturnCode)I am getting capabilities of 3 and 7 for a drive Windows recognizes as a CD-RW drive. I am hesitant to use the Caption property unless there is a documented industry-wide naming convention. Link to comment Share on other sites More sharing options...
MOONLIGHT SONATA Posted November 16, 2005 Share Posted November 16, 2005 @Dear GSMScript has some problem in correctly detecting CD-RW drive. In my machine script just checks my CD-ROM drive and not the CD-RW drive, and then exits. Although if I manually run WMI code (without the Check_For_CDRW.VBS) to get "Caption" feedbacks, it correctly detects Caption for both the drives.@BezalelPlease check http://www.msfn.org/board/index.php?showtopic=49226&st=0 where Martin Zugec described PnP-based Software installation method. He suggests Nero installation on the basis of detecting PnPDeviceId for your CD-RW hardware. His script indeed has section about Nero installation, if i can remember correctly.P.S. "Capabilities" property checking will not help you as correct implementation of it inside a script depends upon the inheritance of this property from CIM_MediaAccessDevice which is still not implementable. That's why you're not getting Value = 4 as you expected. For the time being just check Martin's script and modify as per your need. Post after you finished checking and after you learnt the pros-&-cons of that script. Only then I'll help you into the more attractive realms of WMI-guided world of software installation. I'll be glad if after applying his script you start posting there, in his thread, as only then you'll enter the zone of other software installations apart from this CD-RW drive -based Nero installation. Both Martin and me are interested in taking PnP Device Detection based software installation to a meaningfull stage. I hope you're helped. Link to comment Share on other sites More sharing options...
RogueSpear Posted November 16, 2005 Share Posted November 16, 2005 I've been using WMI in vbs for quite some time now for a number of tasks. Unfortunately detecting hardware capabilities and properties is something where you are often at the mercy of the hardware vendor. It seems optional as to whether or not they implement proper reporting. BIOS strings are a famous example of this. Link to comment Share on other sites More sharing options...
Br4tt3 Posted November 16, 2005 Share Posted November 16, 2005 I agree with RogueSpear... I even had a server where I could detect the cd drive unite correctly, a firmware later and the whole thing was a problem again. Link to comment Share on other sites More sharing options...
Bezalel Posted November 16, 2005 Author Share Posted November 16, 2005 I was searching through the registry to determine where the drive information is kept. I finally found this article Q316529 that mentions that the keys are under HKEY_CURRENT_USER. The really weird thing is that the registry identifies the drive as a CD-R drive and Explorer identifies it as a CD-RW drive. Link to comment Share on other sites More sharing options...
Bezalel Posted December 1, 2005 Author Share Posted December 1, 2005 Based on the information on this page http://www.microsoft.com/technet/scriptcen...04/hey0920.mspx I decided to parse the caption for "RW" Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 1, 2005 Share Posted December 1, 2005 That what the top script does it looks for the RW in theSearchString = objItem.CaptionMyPos = Instr(1, SearchString, "RW") Link to comment Share on other sites More sharing options...
Tracy7011 Posted December 2, 2005 Share Posted December 2, 2005 Is it possible to use this script with diskpart? I need to change my cd to R: (is e: right after install, d: is a zip drive) and make another partition that is e:.Right now I call a bat with command.txt that runs diskpart script thatselects volume 0 (the cd)removes drive letter (it has the e: and I need to create a partition with e:)assign r:create my partition with e: letter.I need a more reliable method of getting the cd drive letter. I tried another method (mapdrive.cmd) that is heavily commented but couldn't get it to work, maybe due to me doing this on w2k.Thanks, Link to comment Share on other sites More sharing options...
Bezalel Posted December 2, 2005 Author Share Posted December 2, 2005 this script will give you a list of CDRom drives and their drive letters.strComputer = "."Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colCDROMDrive = objWMIService.ExecQuery ("Select * from Win32_CDROMDrive")For each objCDROMDrive in colCDROMDrive Wscript.Echo objCDROMDrive.Drive & " " & objCDROMDrive.CaptionNext Link to comment Share on other sites More sharing options...
Tracy7011 Posted December 2, 2005 Share Posted December 2, 2005 Looks like I am going to have to figure out this scripting, I am not sure where to paste this or how to pass this to diskpart. I am a newbie at batchs in windows. (I can sometimes figure out DOS ) I need to figure out the diff of cmd, bat and scripts (scr?). Can I use this syntax in a bat called from command.txt? How do I pass it to diskpart?Thanks for your reply! Sorry for the newbie questions... Link to comment Share on other sites More sharing options...
LaptoniC Posted December 2, 2005 Share Posted December 2, 2005 I developed same util before.Usagetest.exe [options] filenameOptions:/CDR check CD writer/DVD check DVD reader/DVR check DVD writerfor exampletest.exe /CDR /DVD myapp.exe will run myapp.exe only both CD writing and DVD reading capability exist otherwise it will simply exit.When it starts program, it waits until new spawned process ends.Order of options is not important, unrecognized parameters will be ignored but filename must be the last parameter.testcd.zip Link to comment Share on other sites More sharing options...
Sonic Posted December 2, 2005 Share Posted December 2, 2005 yes LaptoniC's progs works like a charm used during this 6 months without problem ... 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