bsharath
asked on
Need to change a list of machine's label as i mention
Hi,
I have the machine names in a file.Need to change all the machines labels to what i mention.I should have a option as C: Label name D: Labelname etc.
What i mention as labelname should be changed to all machines in the file.
Regards
Sharath
I have the machine names in a file.Need to change all the machines labels to what i mention.I should have a option as C: Label name D: Labelname etc.
What i mention as labelname should be changed to all machines in the file.
Regards
Sharath
ASKER
File gets created but no output...
Label are changed?
ASKER
Where should i mention the label name.
I checked no label names changed.
FYI.I have 3 or 4 drives in 1 machine
I checked no label names changed.
FYI.I have 3 or 4 drives in 1 machine
the script change only C and D.
'*** modify with new HD label
labelCname="Drive C"
labelDname="Drive D"
'***
'*** modify with new HD label
labelCname="Drive C"
labelDname="Drive D"
'***
ASKER
I tried but no changes...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
' set-HD-label-all-PCs.vbs
' read the computer computers list from the file c:\computers.txt
' for set C e D HDlabel on file run:
'
' cscript //nologo set-HD-label-all-PCs.vbs >result.txt
'
' Gastone Canali
'
'*** modify with new HD label
labelCname="Drive C"
labelDname="Drive D"
'***
Const ForReading = 1
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.OpenTextFile("C:\Co
do while not objFile.AtEndOfStream
PC = objFile.ReadLine
SEThdinfo (PC)
loop
objFile.Close
sub SEThdinfo(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
if objInstance.deviceID="C:" then
objInstance.VolumeName = labelCname
objInstance.Put_
end if
if objInstance.deviceID="D:" then
objInstance.VolumeName = labelDname
objInstance.Put_
end if
Next
else
getinfo="Error computer not found"
err.clear
end if
WScript.echo strComputer & space(10-len(strComputer))
end sub