Solved

Find Cd drives enabled

Posted on 2007-04-02
20
124 Views
Last Modified: 2008-02-01
Hi,

As my company does not allow cd drives to be enabled so i need a script or tool to find which all machines that have Cd drives ENABLE.

Regards
sharath
0
Comment
Question by:bsharath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 9
20 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18841061
What do you mean by enabled?
Are they stopped simply via policy or have you shut them down some other way?
0
 
LVL 11

Author Comment

by:bsharath
ID: 18841311
I have removed the cable or even disabled in Bios.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18842610
Ah, I see...something like this should tell you then...

Dim objNet:Set objNet=CreateOjbect("Wscript.Network")
Dim objWMI:Set objWMI=GetObject("winmgmts:\\.\root\CIMV2")
Dim colROM:Set colROM=objWMI.ExecQuery("Select & From Win32_LogicalDisk Where MediaType=11") 'MediaType 11 is a CD-ROM
If colROM.Count > 0 Then wscript.echo objNet.ComputerName & " has an enabled CD-ROM".

What you do with this is still 'open'...how are you wanting to poll these devices.  The above would run it on a per-machine basis, but you didn't specify any reporting mechanism.
You could run it in a login script and have it silently report back to a central file...would that work?
0
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
LVL 11

Author Comment

by:bsharath
ID: 18842658
Can we give a list of machine names from which it can scan the machines and report to a file instead of GP.

THX
Sharath
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18842673
Absolutely! Here's a full reporting script - just modify the source file as needed...
Format the file like:
Computer1
Computer2
[...etc...] making sure there's a carriage return <Enter> after each computer name...


'FindCDRoms.vbs
Dim objWMI, colROM
Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objOutput: Set objOutput=objFSO.CreateTextFile("C:\CD-Rom_Report.txt")
arrPCs=Split(objFSO.OpenTextFile(SourceFile).ReadAll, vbNewLine)
For Each PC in arrPCs
  Set objWMI=GetObject("winmgmts:\\" & PC & "\root\CIMV2")
  Set colROM=objWMI.ExecQuery("Select & From Win32_LogicalDisk Where MediaType=11") 'MediaType 11 is a CD-ROM
  If colROM.Count > 0 Then objOutput.WriteLine PC & " has an enabled CD-ROM".
Next
objOutput.Close
Set objOutput=Nothing
Set objWMI=Nothing
Set objFSO=Nothing
Set colRom=Nothing
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18842677
Admittedly, that's untested - so if you find any type-o errors, let me know the line number they're on...
0
 
LVL 11

Author Comment

by:bsharath
ID: 18842729
Where should i specify the source file and its contents
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18842901
There's the first type-o, eh?  Hopefully the last...here's the updated:

'FindCDRoms.vbs
Dim objWMI, colROM
Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objOutput: Set objOutput=objFSO.CreateTextFile("C:\CD-Rom_Report.txt")
SourceFile="C:\Computers.txt"
arrPCs=Split(objFSO.OpenTextFile(SourceFile).ReadAll, vbNewLine)
For Each PC in arrPCs
  Set objWMI=GetObject("winmgmts:\\" & PC & "\root\CIMV2")
  Set colROM=objWMI.ExecQuery("Select & From Win32_LogicalDisk Where MediaType=11") 'MediaType 11 is a CD-ROM
  If colROM.Count > 0 Then objOutput.WriteLine PC & " has an enabled CD-ROM".
Next
objOutput.Close
Set objOutput=Nothing
Set objWMI=Nothing
Set objFSO=Nothing
Set colRom=Nothing
0
 
LVL 11

Author Comment

by:bsharath
ID: 18842935
Error
C:\>cscript abc.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\abc.vbs(9, 78) Microsoft VBScript compilation error: Expected identifier
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18842951
Line 9: Set colROM=objWMI.ExecQuery("Select & From Win32_LogicalDisk Where MediaType=11")

Should read:
Set colROM=objWMI.ExecQuery("Select * From Win32_LogicalDisk Where MediaType=11")

'Changed the & to a *
0
 
LVL 11

Author Comment

by:bsharath
ID: 18843085
Still getting the same error
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18843103
Updated...

'FindCDRoms.vbs
Dim objWMI, colROM
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOutput: Set objOutput = objFSO.CreateTextFile("C:\CD-Rom_Report.txt")
SourceFile = "C:\Computers.txt"
arrPCs = Split(objFSO.OpenTextFile(SourceFile).ReadAll, vbNewLine)
For Each PC In arrPCs
  Set objWMI = GetObject("winmgmts:\\" & PC & "\root\CIMV2")
  Set colROM = objWMI.ExecQuery("Select * From Win32_LogicalDisk Where MediaType=11") 'MediaType 11 is a CD-ROM
  If colROM.Count > 0 Then objOutput.WriteLine PC & " has an enabled CD-ROM"
Next
objOutput.Close
Set objOutput = Nothing
Set objWMI = Nothing
Set objFSO = Nothing
Set colROM = Nothing
0
 
LVL 11

Author Comment

by:bsharath
ID: 18843151
Thanks a lot this worked
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18843159
Happy to help. :^)
0
 
LVL 11

Author Comment

by:bsharath
ID: 18843238
Sorry Sirbounty i get this error when it does not find a machine or machine switched off.

C:\>cscript abc.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\abc.vbs(7, 3) Microsoft VBScript runtime error: The remote server machine doe
s not exist or is unavailable: 'GetObject'
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18843280
You'll need to skip those then...use this:

'FindCDRoms.vbs
On Error Resume Next
Dim objWMI, colROM
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOutput: Set objOutput = objFSO.CreateTextFile("C:\CD-Rom_Report.txt")
SourceFile = "C:\Computers.txt"
arrPCs = Split(objFSO.OpenTextFile(SourceFile).ReadAll, vbNewLine)
For Each PC In arrPCs
  Set objWMI = GetObject("winmgmts:\\" & PC & "\root\CIMV2")
  If Err.Number = 0 Then
    Set colROM = objWMI.ExecQuery("Select * From Win32_LogicalDisk Where MediaType=11") 'MediaType 11 is a CD-ROM
    If colROM.Count > 0 Then objOutput.WriteLine PC & " has an enabled CD-ROM"
  End If
  On Error Goto 0
Next
objOutput.Close
Set objOutput = Nothing
Set objWMI = Nothing
Set objFSO = Nothing
Set colROM = Nothing
0
 
LVL 11

Author Comment

by:bsharath
ID: 18843321
I get the same error.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18843338
Try this version....

'FindCDRoms.vbs
Dim objWMI, colROM
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOutput: Set objOutput = objFSO.CreateTextFile("C:\CD-Rom_Report.txt")
SourceFile = "C:\Computers.txt"
arrPCs = Split(objFSO.OpenTextFile(SourceFile).ReadAll, vbNewLine)
For Each PC In arrPCs
  On Error Resume Next
  Set objWMI = GetObject("winmgmts:\\" & PC & "\root\CIMV2")
  If Err.Number = 0 Then
    Set colROM = objWMI.ExecQuery("Select * From Win32_LogicalDisk Where MediaType=11") 'MediaType 11 is a CD-ROM
    If colROM.Count > 0 Then objOutput.WriteLine PC & " has an enabled CD-ROM"
  End If
  On Error Goto 0
Next
objOutput.Close
Set objOutput = Nothing
Set objWMI = Nothing
Set objFSO = Nothing
Set colROM = Nothing
0
 
LVL 11

Author Comment

by:bsharath
ID: 18843418
Thanks this worked
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18843426
:)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn more about the importance of email disclaimers with our top 10 email disclaimer DOs and DON’Ts.
One of the biggest challenges facing freelancers is balancing multiple projects and deadlines. Organizational skills and time management are key to keeping up with projects and staying on track. Luckily, we’ve curated seven tools to help you focus o…
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…
Where to go on the main page to find the job listings. How to apply to a job that you are interested in from the list that is featured on our Careers page.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question