VBS tutorial: properties – volumename property

Time:2022-5-2

Volumename property

Sets or returns the volume label of the specified drive. Read and write.

object.VolumeName [= newname]

parameter

object

Required. Should beDriveThe name of the object.

newname

Optional. If this parameter is provided, thennewnameFor the specifiedobjectNew name for.

explain

The following code illustrates how to useVolumeNameProperties:

Function ShowVolumeInfo(drvpath)    Dim fso, d, s    Set fso = CreateObject("Scripting.FileSystemObject")    Set d = fso. Getdrive (FS. Getdrivename (FSO. Getabsolutepathname (drvpath))) s = "drive" & d.driveletter & ": -" & d.volumenameshowvolumeinfo = end function