WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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
File Created: 2001:11:08:12:40:34
Last Updated: 2001:11:08:12:40:34