bsharath
asked on
Find all Cdd and DVD with the detail if there is a cd inside the drive.
Hi,
Relared to this Q...
https://www.experts-exchange.com/questions/22746064/Find-all-the-cd-and-dvd-drives-on-my-network.html?cid=239&anchorAnswerId=19652028#a19652028
regards
Sharath
Relared to this Q...
https://www.experts-exchange.com/questions/22746064/Find-all-the-cd-and-dvd-drives-on-my-network.html?cid=239&anchorAnswerId=19652028#a19652028
regards
Sharath
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How about a free bonus?? lol
Realize this will get messy if you run accross alot of pc's with multi drives, but in single drive machines you may like this better, returns to the file as before, added drive letter assigned and volume label if disc is in.
Output:
PCNAME,DriveLetter,VolumeL abel,DiscI n,DriveMod el
'===Start copy: getcdroms.vbs===
' -------------------------- ---------- ---------- ---------- -------'
' getcdroms.vbs
' 'Sample VBScript to query remote computers
' 'and return cdrom model information into csv file.
' ''Author Riley C. aka ZooFan
' '''Version 1.7 - August 2007
' ''''https://www.experts-exchange.com question ID: 22746064
' -------------------------- ---------- ---------- ---------- -------'
'
Option explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 3 'FileObject Access Type
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 'FileObject Format Type
Dim strPcList
Dim arrPcnames()
Dim strResultsFile
Dim dte
Dim tme
Dim objFso
Dim objWshShell
Dim objPCnames
Dim objReadFile
Dim intLneCount
Dim objOutputFile
Dim strCurPath
Dim intPCLoop
Dim strReturn
Dim strTestcon
Set objFso = CreateObject("Scripting.Fi leSystemOb ject")
Set objWshShell = WScript.CreateObject("WScr ipt.Shell" )
strCurPath = CreateObject("Scripting.Fi leSystemOb ject").Get AbsolutePa thName("." )
strPcList = InputBox("Please enter the full path and file" & VbCrLf & "name of the file with the computer names.","Get cdrom drives.")
'Test to make sure file exists if not exit script
If Not objFso.FileExists(strPcLis t) Then
MsgBox "You must enter a valid full path and file name!",vbOKOnly,"Get cdrom drives."
WScript.Quit(0)
Elseif strPcList = "" Then
MsgBox "You must enter a filename!",vbOKOnly,"Get cdrom drives."
WScript.Quit(0)
Else 'File exists continue
dte = Replace(FormatDateTime(dat e(),vbshor tdate),"/" ,"-")
tme = Replace(Replace(FormatDate Time(now() ,vbLongtim e),":","-" )," ","")
strResultsFile = strCurPath & "\" & tme & "_" & dte & ".csv"
If objFSO.FileExists(strResul tsFile) Then
ObjFSO.deleteFile(strResul tsFile)
Else
Set objOutputFile = objFso.CreateTextFile(strR esultsFile )
objOutputFile.Close
End If
MsgBox strResultsFile
Set objPCnames = objFso.GetFile(strPcList)
Set objReadFile = objPCnames.OpenAsTextStrea m(ForReadi ng, TristateUseDefault)
Do Until objReadFile.AtEndOfStream
ReDim Preserve arrPCnames(intLneCount)
arrPCnames(intLneCount) = objReadFile.ReadLine
intLneCount = intLneCount + 1
Loop
objReadFile.Close
Set objOutputFile = objFso.OpenTextFile(strRes ultsFile,F orWriting, TristateUs eDefault)
objOutputFile.WriteLine("C omputer,Dr iveLtr,Lab el,DiscIn, Drives")
For intPCLoop = LBound(arrPCnames) To UBound(arrPCnames)
strTestcon = IsServerOn(arrPCnames(intP CLoop))
If strTestcon = "0" then
strReturn = getcdrom(arrPCnames(intPCL oop))
objOutputFile.WriteLine(ar rPCnames(i ntPCLoop) & "," & strReturn)
Else
objOutputFile.WriteLine(ar rPCnames(i ntPCLoop) & "," & strTestcon)
End If
Next
objOutputFile.Close
MsgBox("Script has completed")
WScript.Quit
End If
Function IsServerOn(strserver)
Dim Testme
Dim intErr
Dim strRegValue
Dim strFileServer
On Error Resume Next
Set Testme = GetObject("winmgmts://" & strserver & "/root/cimv2")
Set strRegValue = GetObject("winmgmts://" & strserver & "/root/default:StdRegProv" )
intErr = Err.Number
If intErr <> 0 Then
IsServerOn = Err.Description
Else
IsServerOn = "0"
End If
On Error GoTo 0
End Function
Function getcdrom(strcomputer)
Dim GetWMIServices
Dim colItems
Dim getcd
Dim obj
Dim discin
Dim strVolume
Dim strDrvLetter
Set GetWMIServices = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!// " & strcomputer & "/root/cimv2")
Set colItems = GetWMIServices.ExecQuery(" Select * from Win32_CDROMDrive")
For Each obj In colItems
getCD = obj.name
strDrvLetter = strDrvLetter & obj.Drive
strVolume = strVolume & "," & obj.VolumeName
discin = discin & "," & obj.MediaLoaded
getcdrom = getcdrom & "," & getcd
Next
getcdrom = strDrvLetter & "," & strVolume & "," & discin & "," & getcdrom
If getcdrom = ",,," Then
getcdrom = "Error reading drive information"
End if
Set GetWMIServices = Nothing
Set colItems = Nothing
End Function
Function readtextfile(strTxtFile, arrname())
On Error Resume Next
Dim intErr, intLines
Dim objTxtLines, objReadFile,objFso
Set objFso = CreateObject("Scripting.Fi leSystemOb ject")
Set objTxtLines = objFso.GetFile(strTxtFile)
Set objReadFile = objTxtLines.OpenAsTextStre am(ForRead ing, TristateUseDefault)
Do Until objReadFile.AtEndOfStream
ReDim Preserve arrname(intLines)
arrname(intLines) = objReadFile.ReadLine
intLines = intLines + 1
Loop
objReadFile.Close
Set objFso = nothing
Set objTxtLines = Nothing
Set objReadFile = Nothing
intErr = Hex(Err.Number)
If intErr <> 0 Then
readtextfile = Err.Description
Else
readtextfile = "0"
End If
On Error GoTo 0
End Function
:-)
zf
Realize this will get messy if you run accross alot of pc's with multi drives, but in single drive machines you may like this better, returns to the file as before, added drive letter assigned and volume label if disc is in.
Output:
PCNAME,DriveLetter,VolumeL
'===Start copy: getcdroms.vbs===
' --------------------------
' getcdroms.vbs
' 'Sample VBScript to query remote computers
' 'and return cdrom model information into csv file.
' ''Author Riley C. aka ZooFan
' '''Version 1.7 - August 2007
' ''''https://www.experts-exchange.com question ID: 22746064
' --------------------------
'
Option explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 3 'FileObject Access Type
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 'FileObject Format Type
Dim strPcList
Dim arrPcnames()
Dim strResultsFile
Dim dte
Dim tme
Dim objFso
Dim objWshShell
Dim objPCnames
Dim objReadFile
Dim intLneCount
Dim objOutputFile
Dim strCurPath
Dim intPCLoop
Dim strReturn
Dim strTestcon
Set objFso = CreateObject("Scripting.Fi
Set objWshShell = WScript.CreateObject("WScr
strCurPath = CreateObject("Scripting.Fi
strPcList = InputBox("Please enter the full path and file" & VbCrLf & "name of the file with the computer names.","Get cdrom drives.")
'Test to make sure file exists if not exit script
If Not objFso.FileExists(strPcLis
MsgBox "You must enter a valid full path and file name!",vbOKOnly,"Get cdrom drives."
WScript.Quit(0)
Elseif strPcList = "" Then
MsgBox "You must enter a filename!",vbOKOnly,"Get cdrom drives."
WScript.Quit(0)
Else 'File exists continue
dte = Replace(FormatDateTime(dat
tme = Replace(Replace(FormatDate
strResultsFile = strCurPath & "\" & tme & "_" & dte & ".csv"
If objFSO.FileExists(strResul
ObjFSO.deleteFile(strResul
Else
Set objOutputFile = objFso.CreateTextFile(strR
objOutputFile.Close
End If
MsgBox strResultsFile
Set objPCnames = objFso.GetFile(strPcList)
Set objReadFile = objPCnames.OpenAsTextStrea
Do Until objReadFile.AtEndOfStream
ReDim Preserve arrPCnames(intLneCount)
arrPCnames(intLneCount) = objReadFile.ReadLine
intLneCount = intLneCount + 1
Loop
objReadFile.Close
Set objOutputFile = objFso.OpenTextFile(strRes
objOutputFile.WriteLine("C
For intPCLoop = LBound(arrPCnames) To UBound(arrPCnames)
strTestcon = IsServerOn(arrPCnames(intP
If strTestcon = "0" then
strReturn = getcdrom(arrPCnames(intPCL
objOutputFile.WriteLine(ar
Else
objOutputFile.WriteLine(ar
End If
Next
objOutputFile.Close
MsgBox("Script has completed")
WScript.Quit
End If
Function IsServerOn(strserver)
Dim Testme
Dim intErr
Dim strRegValue
Dim strFileServer
On Error Resume Next
Set Testme = GetObject("winmgmts://" & strserver & "/root/cimv2")
Set strRegValue = GetObject("winmgmts://" & strserver & "/root/default:StdRegProv"
intErr = Err.Number
If intErr <> 0 Then
IsServerOn = Err.Description
Else
IsServerOn = "0"
End If
On Error GoTo 0
End Function
Function getcdrom(strcomputer)
Dim GetWMIServices
Dim colItems
Dim getcd
Dim obj
Dim discin
Dim strVolume
Dim strDrvLetter
Set GetWMIServices = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colItems = GetWMIServices.ExecQuery("
For Each obj In colItems
getCD = obj.name
strDrvLetter = strDrvLetter & obj.Drive
strVolume = strVolume & "," & obj.VolumeName
discin = discin & "," & obj.MediaLoaded
getcdrom = getcdrom & "," & getcd
Next
getcdrom = strDrvLetter & "," & strVolume & "," & discin & "," & getcdrom
If getcdrom = ",,," Then
getcdrom = "Error reading drive information"
End if
Set GetWMIServices = Nothing
Set colItems = Nothing
End Function
Function readtextfile(strTxtFile, arrname())
On Error Resume Next
Dim intErr, intLines
Dim objTxtLines, objReadFile,objFso
Set objFso = CreateObject("Scripting.Fi
Set objTxtLines = objFso.GetFile(strTxtFile)
Set objReadFile = objTxtLines.OpenAsTextStre
Do Until objReadFile.AtEndOfStream
ReDim Preserve arrname(intLines)
arrname(intLines) = objReadFile.ReadLine
intLines = intLines + 1
Loop
objReadFile.Close
Set objFso = nothing
Set objTxtLines = Nothing
Set objReadFile = Nothing
intErr = Hex(Err.Number)
If intErr <> 0 Then
readtextfile = Err.Description
Else
readtextfile = "0"
End If
On Error GoTo 0
End Function
:-)
zf
If you dont need it just use the other, thought you may like a touch more for good measure.
enjoy!
zf
enjoy!
zf
If you have any other hardware queries let me know those i enjoy doing!! :-)
zf
zf
ASKER
Wow this is a nice one zoofan.An additional benifit for me....:)
Thought you might enjoy the suprise, glad you like.
cheers
zf
cheers
zf
ASKER
I have a Q from a long time.I think you can help...
Is it possible to find all the HDD in a rack server.In what raid are they configured,How many slots they have and how many are free.
esults like.
machinename No of HDD HDD size Raide type Free slots
If you can help i can raise a Q....
THX
Sharath
Is it possible to find all the HDD in a rack server.In what raid are they configured,How many slots they have and how many are free.
esults like.
machinename No of HDD HDD size Raide type Free slots
If you can help i can raise a Q....
THX
Sharath
hmmm.....
I think I can get you some of it. Num of drives yes, size of drive yes, raid type not very confident, and free slots I assume you mean on the controller and that as well not very confident.
These last two in a hardware raid configuration windows would'nt have access to the information as all it see's is one single drive(the array, Which btw would list in No of HDD and size as a single drive) it would know the controller type and thats it as far I know the other information would have to be queried directly from the controller and would be card specific as well as manufacturer specific dont think thats happening or atleast not with my ability.
I can do Num drives, and drive size with no problem, which wil include the raid drive(as windows see's it)
zf
I think I can get you some of it. Num of drives yes, size of drive yes, raid type not very confident, and free slots I assume you mean on the controller and that as well not very confident.
These last two in a hardware raid configuration windows would'nt have access to the information as all it see's is one single drive(the array, Which btw would list in No of HDD and size as a single drive) it would know the controller type and thats it as far I know the other information would have to be queried directly from the controller and would be card specific as well as manufacturer specific dont think thats happening or atleast not with my ability.
I can do Num drives, and drive size with no problem, which wil include the raid drive(as windows see's it)
zf
For example when you go into disk managment you should see the hardware raid as a single Drive entity within windows, aside from low-level machine programming specific to the card model and manufacturer thats all your going to get from it I belive.
My suggestion to start you in a better direction is who makes your raid controller? and what model is it? I will help you look and see if they have any windows based managment/montoring tools.
zf
My suggestion to start you in a better direction is who makes your raid controller? and what model is it? I will help you look and see if they have any windows based managment/montoring tools.
zf
ASKER
Ok Zoofan
I only have HP and dell machines...
I only have HP and dell machines...
ASKER
Any help on these Hardware related Q....
https://www.experts-exchange.com/questions/22748871/I-want-to-find-all-the-machines-in-the-file-how-many-network-cards-they-have.html
https://www.experts-exchange.com/questions/22748873/Is-there-a-way-to-find-all-the-machines-in-the-list-if-all-the-drivers-are-upto-date-If-there-are-ant-drivers-without-drivers.html
https://www.experts-exchange.com/questions/22748871/I-want-to-find-all-the-machines-in-the-file-how-many-network-cards-they-have.html
https://www.experts-exchange.com/questions/22748873/Is-there-a-way-to-find-all-the-machines-in-the-list-if-all-the-drivers-are-upto-date-If-there-are-ant-drivers-without-drivers.html
ASKER
Zoofan.
This is a relevent Q for the previous post printer status page.The same way but to connect through Mstsc.
https://www.experts-exchange.com/questions/22749002/Need-a-customized-mstsc-console.html
This is a relevent Q for the previous post printer status page.The same way but to connect through Mstsc.
https://www.experts-exchange.com/questions/22749002/Need-a-customized-mstsc-console.html
ASKER