Thursday, March 27, 2014

How to rename a volume during OS deployment (or afterwards)

Last time it was needed to change a volume label because of difference volume labels on systems. Searching on the web I found a script which does the job easily. Let's change the volume label for drive C to "System" (for example).

==============================

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDrives = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk where DeviceID = 'C:'")

For Each objDrive in colDrives
    objDrive.VolumeName = "System"
    objDrive.Put_
Next 


==============================

The VBS script can be found here: Script Center
That's all needed!

No comments:

Post a Comment