November 15, 200520 yr 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.
November 15, 200520 yr 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.
November 15, 200520 yr 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
November 15, 200520 yr Author 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.
November 16, 200520 yr @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.
November 16, 200520 yr 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.
November 16, 200520 yr 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.
November 16, 200520 yr Author 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.
December 1, 200520 yr Author Based on the information on this page http://www.microsoft.com/technet/scriptcen...04/hey0920.mspx I decided to parse the caption for "RW"
December 1, 200520 yr That what the top script does it looks for the RW in theSearchString = objItem.CaptionMyPos = Instr(1, SearchString, "RW")
December 2, 200520 yr 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,
December 2, 200520 yr Author 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
December 2, 200520 yr 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...
December 2, 200520 yr 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
December 2, 200520 yr yes LaptoniC's progs works like a charm used during this 6 months without problem ...
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now