Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


How to Set Disk Volume Name

Keywords:   set volume name  SetVolumeLabelA

Question:

Is there a builtin WinBatch command for setting the volume name of a disk?

Answer:

Sorry no built-in function to SET the volume name of a drive.
  1. You could try the DOS "label" command
    >label c: mydrive
    
    would set the label of c: to "mydrive", e.g.,
    cmd=Environment("COMSPEC")
    Run(cmd, "/c LABEL C:CANDY") 
    

  2. You can use the following DllCall: (You can replace "C:\" with the drive letter of any volume you wish to rename.)
    Kernel32=strcat(dirwindows(1),"Kernel32.DLL")
    RetVal = DLLCall(Kernel32,long:"SetVolumeLabelA",lpstr:"C:\",lpstr:"NewVolumeName")
    ;
    ; RetVal will be 0 if there is an error
    ; or Non-Zero if the call succeeded.
    ;
    

Article ID:   W14860