Search the Community
Showing results for tags 'label changer'.
-
Hi, just posting an example on how to change a drive label, it lists labels and drive type, you just insert the drive letter and the label you want and press change. #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Resources\Terminal.ico #AutoIt3Wrapper_Res_Icon_Add=Resources\Terminal.ico #AutoIt3Wrapper_Run_Tidy=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) Local $Change, $List, $Label, $Drive, $sType, $aArray, $sLabel, $Input1, $Input2, $Volume, $Letter, $LabelChange, $cListView, $iFreeSpace $Form1 = GUICreate("Volume Label Changer", 425, 370, 190, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") $cListView = GUICtrlCreateListView("Drive Letter|Label|Type|Free Space", 8, 64, 410, 300) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100) $Exit = GUICtrlCreateButton("Exit", 184, 34, 75, 25) GUICtrlSetOnEvent($Exit, "Close") $Change = GUICtrlCreateButton("Change to", 96, 34, 75, 25) GUICtrlSetOnEvent($Change, "Change") $List = GUICtrlCreateButton("List Drives", 8, 34, 75, 25) GUICtrlSetOnEvent($List, "List") $Label1 = GUICtrlCreateLabel("Volume to change", 8, 8, 91, 17) $Label2 = GUICtrlCreateLabel("Set to:", 176, 8, 35, 17) $Input1 = GUICtrlCreateInput("", 104, 8, 57, 21) $Input2 = GUICtrlCreateInput("", 216, 8, 57, 21) GUISetState(@SW_SHOW) Func List() _GUICtrlListView_DeleteAllItems($clistview) ;GUICtrlCreateListViewItem("=====|=====|=====|=====", $clistview) $aArray = DriveGetDrive('ALL') If @error Then MsgBox(4096, "DriveGetDrive", "It appears an error occurred.") Else For $i = 1 To $aArray[0] $sLabel = DriveGetLabel($aArray[$i] & "\") If @error = 1 Then $sLabel = "<NO LABEL>" EndIf $sType = DriveGetType($aArray[$i] & "\") If @error = 1 Then $sType = "<NO TYPE>" EndIf $iFreeSpace = DriveSpaceFree($aArray[$i] & "\") StringUpper($sLabel) GUICtrlCreateListViewItem(StringUpper($aArray[$i])&'|'&$sLabel&'|'&$sType&'|'&$iFreeSpace, $cListView) Next EndIf EndFunc ;==>List Func Change() $Volume = GUICtrlRead($Input1) $Volume = StringUpper($Volume & ':') $Letter = GUICtrlRead($Input2) $Letter = StringUpper($Letter) $sType = DriveGetType($Volume) If $sType = ('CDROM') Then MsgBox(4096, 'Volume Info', "Drive type is CDROM can't change these.") Else $LabelChange = DriveSetLabel($Volume, $Letter) If $LabelChange = 0 Then MsgBox(4096, "Volume Info", "Failure changing label, Wrong letter or too many characters." & @CRLF & "Letter and Label entered: " & $Volume & ' + ' & $Letter) ;Else ;MsgBox(4096, "Volume Info", "Set Drive Label on " & $Volume & " To: " & $Letter) EndIf EndIf List() EndFunc ;==>Change Func Close() Exit EndFunc ;==>Close Do Sleep(100) Until $Form1 = 0 EDIT: removed GUIGetMsg, as GUIOnEventMode was set to 1, rendering the first useless. UPDATE: MsgBoxes are now only used for errors, listbox added to display multiple drive informations, check caps. Volume Label Changer.au3
- 4 replies
-
- drive label changer
- volume label changer
- (and 3 more)