bsharath
asked on
Get all the machines volume label names to a file
Hi,
I want to get all the volume label names to a file.I have all the machine names in a txt file.Need a script to scan the machines and get all the drives label names.
Machinename C: Labelname D: Labelname and so on.
Regards
Sharath
I want to get all the volume label names to a file.I have all the machine names in a txt file.Need a script to scan the machines and get all the drives label names.
Machinename C: Labelname D: Labelname and so on.
Regards
Sharath
'
' get-HD-label-all-PCs.vbs
' read the computer computers list from the file c:\computers.txt
' for get output on file run:
'
' cscript //nologo get-HD-label-all-PCs.vbs >result.txt
'
' Gastone Canali
'
Const ForReading = 1
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objFile = objFSO.OpenTextFile("C:\Co mputers.tx t", ForReading)
do while not objFile.AtEndOfStream
PC = objFile.ReadLine
Gethdinfo (PC)
loop
objFile.Close
sub Gethdinfo(strComputer)
getinfo=""
On Error Resume Next
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/CIMV2" )
Set colInstances = objWMIService.ExecQuery( "SELECT * FROM Win32_LogicalDisk where driveType=3", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )
If Err.Number = 0 then
For Each objInstance In colInstances
getinfo=getinfo & " " & objInstance.deviceID &" " & objInstance.volumename
Next
else
getinfo="Error computer not found"
err.clear
end if
WScript.echo strComputer & space(10-len(strComputer)) &": " & getinfo
end sub
' get-HD-label-all-PCs.vbs
' read the computer computers list from the file c:\computers.txt
' for get output on file run:
'
' cscript //nologo get-HD-label-all-PCs.vbs >result.txt
'
' Gastone Canali
'
Const ForReading = 1
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.OpenTextFile("C:\Co
do while not objFile.AtEndOfStream
PC = objFile.ReadLine
Gethdinfo (PC)
loop
objFile.Close
sub Gethdinfo(strComputer)
getinfo=""
On Error Resume Next
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/CIMV2" )
Set colInstances = objWMIService.ExecQuery( "SELECT * FROM Win32_LogicalDisk where driveType=3", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )
If Err.Number = 0 then
For Each objInstance In colInstances
getinfo=getinfo & " " & objInstance.deviceID &" " & objInstance.volumename
Next
else
getinfo="Error computer not found"
err.clear
end if
WScript.echo strComputer & space(10-len(strComputer))
end sub
ASKER
I tried tha same way as mentioned.TRhe file is creating but no data in the results.txt
try only:
cscript //nologo get-HD-label-all-PCs.vbs
cscript //nologo get-HD-label-all-PCs.vbs
ASKER
C:\>cscript //nologo get-HD-label-all-PCs.vbs
hydsophos : C: D: Data
: Error computer not found
: Error computer not found
: Error computer not found
hydsophos : C: D: Data
: Error computer not found
: Error computer not found
: Error computer not found
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://msdn2.microsoft.com/en-us/library/system.io.driveinfo.getdrives(VS.80).aspx