Simpel Posted July 31, 2018 Share Posted July 31, 2018 Hi. I just wrote a script to hide some drives. I don't want to see some of them because they are fixed backup drives or drives including only licenses (dongle). expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> ;~ #include <NoFocusLines.au3> ; UDF to hide dots around checkboxes ;~ _NoFocusLines_Global_Set() ; UDF to hide dots around checkboxes Global $g_sKeyName = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" Global $g_sValueName = "NoDrives" Local $iRegistryReadValue = RegRead($g_sKeyName, $g_sValueName) If @error Then $iRegistryReadValue = 0 Global $g_hCheckboxLW[26] ; one checkbox for every drive letter Local $iPowerOfTwo Global $hGui = GUICreate("Hide Drives", 26 * 40 + 20, 95) For $i = 0 To 25 $g_hCheckboxLW[$i] = GUICtrlCreateCheckbox(Chr($i + 65) & ":", 10 + $i * 40, 15, -1, -1, BitOR($BS_CHECKBOX, $BS_AUTOCHECKBOX, $BS_RIGHTBUTTON, $BS_RIGHT)) $iPowerOfTwo = 2 ^ $i If BitAND($iRegistryReadValue, $iPowerOfTwo) = $iPowerOfTwo Then GUICtrlSetState(-1, $GUI_CHECKED) Next Local $hCheckAll = GUICtrlCreateButton("Check all drives", 10, 50, 200, 30) Local $hCheckNone = GUICtrlCreateButton("Uncheck all drives", 220, 50, 200, 30) Local $hSetToRegistry = GUICtrlCreateButton("Set to registry", 840, 50, 200, 30) GUISetState(@SW_SHOW) Local $sMsg While 1 $sMsg = GUIGetMsg() Switch $sMsg Case $GUI_EVENT_CLOSE Exit Case $hCheckAll For $i = 0 To 25 GUICtrlSetState($g_hCheckboxLW[$i], $GUI_CHECKED) Next Case $hCheckNone For $i = 0 To 25 GUICtrlSetState($g_hCheckboxLW[$i], $GUI_UNCHECKED) Next Case $hSetToRegistry _SetToRegistry() If Not @error Then MsgBox(0, 'Success', "Drives are set hidden to registry." & @CRLF & @CRLF & "Please logoff to activate.") Else MsgBox(0, 'Error', "Can't write to registry.") EndIf EndSwitch WEnd Func _SetToRegistry() Local $iValue = 0 For $i = 0 To 25 If GUICtrlRead($g_hCheckboxLW[$i]) = $GUI_CHECKED Then $iValue += 2 ^ $i EndIf Next ConsoleWrite($iValue & @CRLF) Local $iSuccess = RegWrite($g_sKeyName, $g_sValueName, "REG_DWORD", $iValue) Return SetError(@error, 0, $iSuccess) EndFunc This script works for the current user. Regards, Simpel ModemJunki and Earthshine 1 1 SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
ModemJunki Posted July 31, 2018 Share Posted July 31, 2018 Thank you, Simpel! I also have an backupdrive that I wish to hide from Explorer. For anyone else browsing - this hides the drive only from Windows Explorer, you can still access the drive by using start->run-><input drive letter with colon>->enter or from the command line, from scripts, etc.. This is super! Always carry a towel. Link to comment Share on other sites More sharing options...
Simpel Posted July 31, 2018 Author Share Posted July 31, 2018 And you can access the drive from windows explorer too. You only have to type the letter followed by colon in the address bar. ModemJunki 1 SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now