'==================================================================== ' Registry tutorial - How to make your computer more secure by hiding ' drives of your choice. ' ' This program will show / hide drives from you - the current user. '==================================================================== '==================================================================================== ' Should you have any problems restoring (seeing) a drive and this ' program will not work for you, then you can always use regedit.exe ' and go to... ' ' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer ' ' Set the NoDrives entry to zero, or just delete it - then restart your computer. '==================================================================================== '===================================================================== ' USE: ' ' Select a drive to hide it, then click Apply. ' Wait for your desktop / taskbar to restart and check explorer for ' the drive. ' ' Repeat the process to see the drive again. ' ' I WOULD SUGGEST THAT YOU DO NOT HIDE YOUR SYSTEM (C) DRIVE. ' '===================================================================== '================================================= ' Compile as single file and run as Administrator! '================================================= $ifdef WIN32 $define WIN32_LEAN_AND_MEAN $endif $define __winreg_inc__ 'Always use this with Registry.inc if you have windowssdk.inc included. $include "windowssdk.inc" $include "Registry.inc" $include "Psapi.inc" $include "TlHelp32.inc" declare "kernel32",GetDriveTypeFL alias GetDriveTypeA(dir:string),int declare "kernel32",GetLogicalDrivesFL alias GetLogicalDrives(),int 'DECLARE "kernel32",GetLogicalDriveStringsA(length:INT,pStr:STRING),INT 'DECLARE "Kernel32",GetVolumeInformationA(Path:STRING,VolumeName:STRING,nVolumeLen:INT,Serial:POINTER,MaxComponentLength:POINTER,FileSystemFlags:POINTER,FileSystemName:STRING,FileSystemNameLen:INT),INT 'declare "kernel32",GetFileAttributesAFL alias GetFileAttributesA(fn:string),int '==================================================================== ' This first section of code is used to make sure we have full access ' to the registry. '==================================================================== DWORD aProcesses[1024], cbNeeded, cProcesses, procId, bProcess[512] handle hProcess, hTokenSelf, hProcSelf hProcSelf = OpenProcess( PROCESS_ALL_ACCESS,FALSE,GetCurrentProcessId() ) OpenProcessToken(hProcSelf,TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY ,&hTokenSelf) SetPrivilege(hTokenSelf,"SeDebugPrivilege",true) '======================== ' Now some constants etc. '======================== const Check1 = 1 const Check2 = 2 const Check3 = 3 const Check4 = 4 const Check5 = 5 const Check6 = 6 const Check7 = 7 const Check8 = 8 const Check9 = 9 const Check10 = 10 const Check11 = 11 const Check12 = 12 const Check13 = 13 const Check14 = 14 const Check15 = 15 const Check16 = 16 const Check17 = 17 const Check18 = 18 const Check19 = 19 const Check20 = 20 const Check21 = 21 const Check22 = 22 const Check23 = 23 const Check24 = 24 const Check25 = 25 const Check26 = 26 const BUTTON_1 = 51 const BUTTON_2 = 52 const BUTTON_3 = 53 WINDOW win int x = 0 int DriveCount = 0 int DriveA,DriveB,DriveC,DriveD,DriveE,DriveF,DriveG,DriveH,DriveI,DriveJ,DriveK,DriveL,DriveM int DriveN,DriveO,DriveP,DriveQ,DriveR,DriveS,DriveT,DriveU,DriveV,DriveW,DriveX,DriveY,DriveZ string Drive,rtn,dir int i,l,result Def name as string 'Buffer for lpRootName Def filesystemname as string 'This will be used to return the file system name (FAT FAT32 NTFS) Def DrivePath as string ' This string holds what path we will use in the call int flags,serialnumber,maxcomponentlength ' Integers of the call flags=0:serialnumber=0:maxcomponentlength=0 ' Make sure there all set to zero '=============================================================================== ' Here we get the value of the registry entry 'NoDrives'. ' Since this entry does not normally ship with Windows, it's unlikely to be on ' your machine, and so the first time you run this program the value will be ' zero. ' ' However, once you start hiding drives it will have some value stored in it. '=============================================================================== DriveCount = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives")) '============================================================================ ' Here I will store a 1 or 0 for each drive that is hidden (1) or showing (0) ' I found this much easier than trying to calculate it. '============================================================================ DriveA = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "A")) DriveB = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "B")) DriveC = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "C")) DriveD = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "D")) DriveE = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "E")) DriveF = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "F")) DriveG = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "G")) DriveH = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "H")) DriveI = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "I")) DriveJ = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "J")) DriveK = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "K")) DriveL = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "L")) DriveM = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "M")) DriveN = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "N")) DriveO = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "O")) DriveP = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "P")) DriveQ = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "Q")) DriveR = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "R")) DriveS = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "S")) DriveT = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "T")) DriveU = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "U")) DriveV = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "V")) DriveW = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "W")) DriveX = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "X")) DriveY = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "Y")) DriveZ = val(RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", "Z")) GetDriveNames() 'Get the drive label name if available and store it. ALabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","A") BLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","B") CLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","C") DLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","D") ELabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","E") FLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","F") GLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","G") HLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","H") ILabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","I") JLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","J") KLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","K") LLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","L") MLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","M") NLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","N") OLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","O") PLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","P") QLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","Q") RLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","R") SLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","S") TLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","T") ULabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","U") VLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","V") WLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","W") XLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","X") YLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","Y") ZLabel = RegGetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","Z") '=============================== ' Open a window and let's begin. '=============================== OpenWindow win,0,0,900,590,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU,0,"Hide / Show drives.",&win_handler 'Left hand side of screen CONTROL win,@CHECKBOX,"Hide Drive (A) "+ALabel,29,76,345,25,0, Check1 CONTROL win,@CHECKBOX,"Hide Drive (B) "+BLabel,29,108,345,25,0,Check2 CONTROL win,@CHECKBOX,"Hide Drive (C) "+Clabel,29,140,345,25,0,Check3 CONTROL win,@CHECKBOX,"Hide Drive (D) "+DLabel,29,172,345,25,0,Check4 CONTROL win,@CHECKBOX,"Hide Drive (E) "+ELabel,29,205,345,25,0,Check5 CONTROL win,@CHECKBOX,"Hide Drive (F) "+FLabel,29,236,345,25,0,Check6 CONTROL win,@CHECKBOX,"Hide Drive (G) "+GLabel,29,268,345,25,0,Check7 CONTROL win,@CHECKBOX,"Hide Drive (H) "+HLabel,29,298,345,25,0,Check8 CONTROL win,@CHECKBOX,"Hide Drive (I) "+ILabel,29,329,345,25,0,Check9 CONTROL win,@CHECKBOX,"Hide Drive (J) "+JLabel,29,358,345,25,0,Check10 CONTROL win,@CHECKBOX,"Hide Drive (K) "+KLabel,29,388,345,25,0,Check11 CONTROL win,@CHECKBOX,"Hide Drive (L) "+LLAbel,28,417,345,25,0,Check12 CONTROL win,@CHECKBOX,"Hide Drive (M) "+MLabel,29,446,345,25,0,Check13 'Right hand side of the screen CONTROL win,@CHECKBOX,"Hide Drive (N) "+NLabel,450,76,345,25,0, Check14 CONTROL win,@CHECKBOX,"Hide Drive (O) "+OLabel,450,108,345,25,0,Check15 CONTROL win,@CHECKBOX,"Hide Drive (P) "+PLabel,450,140,344,25,0,Check16 CONTROL win,@CHECKBOX,"Hide Drive (Q) "+QLabel,450,172,346,25,0,Check17 CONTROL win,@CHECKBOX,"Hide Drive (R) "+RLabel,450,205,347,25,0,Check18 CONTROL win,@CHECKBOX,"Hide Drive (S) "+SLabel,450,236,347,25,0,Check19 CONTROL win,@CHECKBOX,"Hide Drive (T) "+TLabel,450,268,348,25,0,Check20 CONTROL win,@CHECKBOX,"Hide Drive (U) "+ULabel,450,298,347,25,0,Check21 CONTROL win,@CHECKBOX,"Hide Drive (V) "+VLabel,450,329,347,25,0,Check22 CONTROL win,@CHECKBOX,"Hide Drive (W) "+WLabel,450,358,346,25,0,Check23 CONTROL win,@CHECKBOX,"Hide Drive (X) "+XLabel,450,388,347,25,0,Check24 CONTROL win,@CHECKBOX,"Hide Drive (Y) "+YLabel,450,417,348,25,0,Check25 CONTROL win,@CHECKBOX,"Hide Drive (Z) "+ZLabel,450,446,348,25,0,Check26 CONTROL win,@BUTTON,"Apply",28,500,100,25,0,BUTTON_1 CONTROL win,@BUTTON,"Show All Drives",450,500,260,25,0,BUTTON_2 CONTROL win,@BUTTON,"Quit",790,500,80,25,0,BUTTON_3 if DriveA = 1 setcontroltext(win,Check3,"Show Drive (A) "+ALabel) endif if DriveB = 1 setcontroltext(win,Check3,"Show Drive (B) "+BLabel) endif if DriveC = 1 setcontroltext(win,Check3,"Show Drive (C) "+CLabel) endif if DriveD = 1 setcontroltext(win,Check4,"Show Drive (D) "+DLabel) endif if DriveE = 1 setcontroltext(win,Check5,"Show Drive (E) "+ELabel) endif if DriveF = 1 setcontroltext(win,Check6,"Show Drive (F) "+FLabel) endif if DriveG = 1 setcontroltext(win,Check7,"Show Drive (G) "+GLabel) endif if DriveH = 1 setcontroltext(win,Check8,"Show Drive (H) "+HLabel) endif if DriveI = 1 setcontroltext(win,Check9,"Show Drive (I) "+ILabel) endif if DriveJ = 1 setcontroltext(win,Check10,"Show Drive (J) "+JLabel) endif if DriveK = 1 setcontroltext(win,Check11,"Show Drive (K) "+KLabel) endif if DriveL = 1 setcontroltext(win,Check12,"Show Drive (L) "+LLabel) endif if DriveM = 1 setcontroltext(win,Check13,"Show Drive (M) "+MLabel) endif if DriveN = 1 setcontroltext(win,Check14,"Show Drive (N) "+NLabel) endif if DriveO = 1 setcontroltext(win,Check15,"Show Drive (O) "+OLabel) endif if DriveP = 1 setcontroltext(win,Check16,"Show Drive (P) "+PLabel) endif if DriveQ = 1 setcontroltext(win,Check17,"Show Drive (Q) "+QLabel) endif if DriveR = 1 setcontroltext(win,Check18,"Show Drive (R) "+RLabel) endif if DriveS = 1 setcontroltext(win,Check19,"Show Drive (S) "+SLabel) endif if DriveT = 1 setcontroltext(win,Check20,"Show Drive (T) "+TLabel) endif if DriveU = 1 setcontroltext(win,Check21,"Show Drive (U) "+ULabel) endif if DriveV = 1 setcontroltext(win,Check22,"Show Drive (V) "+VLabel) endif if DriveW = 1 setcontroltext(win,Check23,"Show Drive (W) "+WLabel) endif if DriveX = 1 setcontroltext(win,Check24,"Show Drive (X) "+XLabel) endif if DriveY = 1 setcontroltext(win,Check25,"Show Drive (Y) "+YLabel) endif if DriveZ = 1 setcontroltext(win,Check26,"Show Drive (Z) "+ZLabel) endif for x = 1 to 26 SETFONT win,"Arial",12,500,0,x SETCONTROLCOLOR win,x,RGB(0,0,0),rgb(255,255,255) next x SETFONT win,"Arial",12,500,0,BUTTON_1 SETFONT win,"Arial",12,500,0,BUTTON_2 SETFONT win,"Arial",12,500,0,BUTTON_3 WAITUNTIL ISWINDOWCLOSED(win) END SUB win_handler(), INT SELECT @MESSAGE CASE @IDCREATE CENTERWINDOW win /* Initialize any controls here */ CASE @IDCONTROL SELECT @CONTROLID CASE BUTTON_1 'Apply '==================================================================== ' When the Apply button is clicked, we will check to see which drives ' have been selected. ' ' If the drive is visable, then we will add it's corresponding drive ' number to the NoDrives registry entry. ' i.e. If drive A is selected, we will add 1 to the NoDrives count ' we would add 2 for drive B, 4 for drive C and so on... ' ' If the drive selected is hidden, then we will subtract it's number ' from NoDrives. '==================================================================== IF @NOTIFYCODE = 0 if getstate(win,Check1) = 1 'A if DriveA = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "A") DriveCount += 1 setcontroltext(win,Check1,"Show Drive (A) "+ALabel) DriveA = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "A") DriveCount = DriveCount - 1 setcontroltext(win,Check1,"Hide Drive (A) "+ALabel) DriveA = 0 endif setstate(win,Check1,0) endif if getstate(win,Check2) = 1 'B if DriveB = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "B") DriveCount += 2 setcontroltext(win,Check2,"Show Drive (B) " +BLabel) DriveB = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "B") DriveCount = DriveCount - 2 setcontroltext(win,Check2,"Hide Drive (B) " +BLabel) DriveB = 0 endif setstate(win,Check2,0) endif if getstate(win,Check3) = 1 'C if DriveC = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "C") DriveCount += 4 setcontroltext(win,Check3,"Show Drive (C) " +CLabel) DriveC = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "C") DriveCount = DriveCount - 4 setcontroltext(win,Check3,"Hide Drive (C) " +CLabel) DriveC = 0 endif setstate(win,Check3,0) endif if getstate(win,Check4) = 1 'D if DriveD = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "D") DriveCount += 8 setcontroltext(win,Check4,"Show Drive (D) " +DLabel) DriveD = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "D") DriveCount = DriveCount - 8 setcontroltext(win,Check4,"Hide Drive (D) " +DLabel) DriveD = 0 endif setstate(win,Check4,0) endif if getstate(win,Check5) = 1 'E if DriveE = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "E") DriveCount += 16 setcontroltext(win,Check5,"Show Drive (E) " +ELabel) DriveE = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "E") DriveCount = DriveCount - 16 setcontroltext(win,Check5,"Hide Drive (E) " +ELabel) DriveE = 0 endif setstate(win,Check5,0) endif if getstate(win,Check6) = 1 'F if DriveF = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "F") DriveCount += 32 setcontroltext(win,Check6,"Show Drive (F) " +FLabel) DriveF = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "F") DriveCount = DriveCount - 32 setcontroltext(win,Check6,"Hide Drive (F) " +FLabel) DriveF = 0 endif setstate(win,Check6,0) endif if getstate(win,Check7) = 1 'G if DriveG = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "G") DriveCount += 64 setcontroltext(win,Check7,"Show Drive (G) " +GLabel) DriveG = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "G") DriveCount = DriveCount - 64 setcontroltext(win,Check7,"Hide Drive (G) " +GLabel) DriveG = 0 endif setstate(win,Check7,0) endif if getstate(win,Check8) = 1 'H if DriveH = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "H") DriveCount += 128 setcontroltext(win,Check8,"Show Drive (H) " +HLabel) DriveH = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "H") DriveCount = DriveCount - 128 setcontroltext(win,Check8,"Hide Drive (H) " +HLabel) DriveH = 0 endif setstate(win,Check8,0) endif if getstate(win,Check9) = 1 'I if DriveI = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "I") DriveCount += 256 setcontroltext(win,Check9,"Show Drive (I) " +ILabel) DriveI = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "I") DriveCount = DriveCount - 256 setcontroltext(win,Check9,"Hide Drive (I) " +ILabel) DriveI = 0 endif setstate(win,Check9,0) endif if getstate(win,Check10) = 1 'J if DriveJ = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "J") DriveCount += 512 setcontroltext(win,Check10,"Show Drive (J) " +JLabel) DriveJ = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "J") DriveCount = DriveCount - 512 setcontroltext(win,Check10,"Hide Drive (J) " +JLabel) DriveJ = 0 endif setstate(win,Check10,0) endif if getstate(win,Check11) = 1 'K if DriveK = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "K") DriveCount += 1024 setcontroltext(win,Check11,"Show Drive (K) " +KLabel) DriveK = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "K") DriveCount = DriveCount - 1024 setcontroltext(win,Check11,"Hide Drive (K) " +KLabel) DriveK = 0 endif setstate(win,Check11,0) endif if getstate(win,Check12) = 1 'L if DriveL = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "L") DriveCount += 2048 setcontroltext(win,Check12,"Show Drive (L) " +LLabel) DriveL = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "L") DriveCount = DriveCount - 2048 setcontroltext(win,Check12,"Hide Drive (L) " +LLabel) DriveL = 0 endif setstate(win,Check12,0) endif if getstate(win,Check13) = 1 'M if DriveM = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "M") DriveCount += 4096 setcontroltext(win,Check13,"Show Drive (M) " +MLabel) DriveM = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "M") DriveCount = DriveCount - 4096 setcontroltext(win,Check13,"Hide Drive (M) " +MLabel) DriveM = 0 endif setstate(win,Check13,0) endif if getstate(win,Check14) = 1 'N if DriveN = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "N") DriveCount += 8192 setcontroltext(win,Check14,"Show Drive (N) " +NLabel) DriveN = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "N") DriveCount = DriveCount - 8192 setcontroltext(win,Check14,"Hide Drive (N) " +NLabel) DriveN = 0 endif setstate(win,Check14,0) endif if getstate(win,Check15) = 1 'O if DriveO = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "O") DriveCount += 16384 setcontroltext(win,Check15,"Show Drive (O) " +OLabel) DriveM = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "O") DriveCount = DriveCount - 16384 setcontroltext(win,Check15,"Hide Drive (O) " +OLabel) DriveO = 0 endif setstate(win,Check15,0) endif if getstate(win,Check16) = 1 'P if DriveP = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "P") DriveCount += 32768 setcontroltext(win,Check16,"Show Drive (P) " +PLabel) DriveP = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "P") DriveCount = DriveCount - 32768 setcontroltext(win,Check16,"Hide Drive (P) " +PLabel) DriveP = 0 endif setstate(win,Check16,0) endif if getstate(win,Check17) = 1 'Q if DriveQ = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "Q") DriveCount += 65536 setcontroltext(win,Check17,"Show Drive (Q) " +QLabel) DriveQ = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Q") DriveCount = DriveCount - 65536 setcontroltext(win,Check17,"Hide Drive (Q) " +QLabel) DriveQ = 0 endif setstate(win,Check17,0) endif if getstate(win,Check18) = 1 'R if DriveR = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "R") DriveCount += 131072 setcontroltext(win,Check18,"Show Drive (R) " +RLabel) DriveR = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "R") DriveCount = DriveCount - 131072 setcontroltext(win,Check18,"Hide Drive (R) " +RLabel) DriveR = 0 endif setstate(win,Check18,0) endif if getstate(win,Check19) = 1 'S if DriveS = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "S") DriveCount += 262144 setcontroltext(win,Check19,"Show Drive (S) " +SLabel) DriveS = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "S") DriveCount = DriveCount - 262144 setcontroltext(win,Check19,"Hide Drive (S) " +SLabel) DriveS = 0 endif setstate(win,Check19,0) endif if getstate(win,Check20) = 1 'T if DriveT = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "T") DriveCount += 524288 setcontroltext(win,Check20,"Show Drive (T) " +TLabel) DriveT = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "T") DriveCount = DriveCount - 524288 setcontroltext(win,Check20,"Hide Drive (T) " +TLabel) DriveT = 0 endif setstate(win,Check20,0) endif if getstate(win,Check21) = 1 'U if DriveU = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "U") DriveCount += 1048576 setcontroltext(win,Check21,"Show Drive (U) " +ULabel) DriveU = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "U") DriveCount = DriveCount - 1048576 setcontroltext(win,Check21,"Hide Drive (U) " +ULabel) DriveU = 0 endif setstate(win,Check21,0) endif if getstate(win,Check22) = 1 'V if DriveV = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "V") DriveCount += 2097152 setcontroltext(win,Check22,"Show Drive (V) " +VLabel) DriveV = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "V") DriveCount = DriveCount - 2097152 setcontroltext(win,Check22,"Hide Drive (V) " +VLabel) DriveV = 0 endif setstate(win,Check22,0) endif if getstate(win,Check23) = 1 'W if DriveW = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "W") DriveCount += 4194304 setcontroltext(win,Check23,"Show Drive (W) " +WLabel) DriveW = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "W") DriveCount = DriveCount - 4194304 setcontroltext(win,Check23,"Hide Drive (W) " +WLabel) DriveW = 0 endif setstate(win,Check23,0) endif if getstate(win,Check24) = 1 'X if DriveX = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "X") DriveCount += 8388608 setcontroltext(win,Check24,"Show Drive (X) " +XLabel) DriveX = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "X") DriveCount = DriveCount - 8388608 setcontroltext(win,Check24,"Hide Drive (X) " +XLabel) DriveX = 0 endif setstate(win,Check24,0) endif if getstate(win,Check25) = 1 'Y if DriveY = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "Y") DriveCount += 16777216 setcontroltext(win,Check25,"Show Drive (Y) " +YLabel) DriveY = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Y") DriveCount = DriveCount - 16777216 setcontroltext(win,Check25,"Hide Drive (Y) " +YLabel) DriveY = 0 endif setstate(win,Check25,0) endif if getstate(win,Check26) = 1 'Z if DriveZ = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 1, "Z") DriveCount += 33554432 setcontroltext(win,Check26,"Show Drive (Z) " +ZLabel) DriveZ = 1 else result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Z") DriveCount = DriveCount - 33554432 setcontroltext(win,Check26,"Hide Drive (Z) " +ZLabel) DriveZ = 0 endif setstate(win,Check26,0) endif '===================================== ' Now we will store the NoDrive count. '===================================== result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", DriveCount, "NoDrives") '========================================================== ' Here we will stop explorer.exe, which closes the desktop, ' Windows should re-start it in a second or two for you. ' ' If not, use Task Manager (new task) to run it again or ' failing that, restart your computer. '========================================================== retval = findPIDByName("explorer.exe") if retval <>0 killProcess(retval) 'Here KillProcess stops an exe OR use GOSUB DOSOMETHINGELSE etc.... ELSE 'print "Process Not Found." ENDIF CASE BUTTON_2 'Show all drives IF @NOTIFYCODE = 0 DriveCount = 0 DriveA = 0 DriveB = 0 DriveC = 0 DriveD = 0 DriveE = 0 DriveF = 0 DriveG = 0 DriveH = 0 DriveI = 0 DriveJ = 0 DriveK = 0 DriveL = 0 result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", 0, "NoDrives") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "A") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "B") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "C") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "D") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "E") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "F") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "G") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "H") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "I") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "J") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "K") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "L") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "M") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "N") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "O") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "P") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Q") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "R") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "S") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "T") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "U") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "V") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "W") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "X") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Y") result = RegSetDWValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives", 0, "Z") setcontroltext(win,Check1, "Hide Drive (A) " +ALAbel) setcontroltext(win,Check2, "Hide Drive (B) " +BLAbel) setcontroltext(win,Check3, "Hide Drive (C) " +CLAbel) setcontroltext(win,Check4, "Hide Drive (D) " +DLAbel) setcontroltext(win,Check5, "Hide Drive (E) " +ELAbel) setcontroltext(win,Check6, "Hide Drive (F) " +FLAbel) setcontroltext(win,Check7, "Hide Drive (G) " +GLAbel) setcontroltext(win,Check8, "Hide Drive (H) " +HLAbel) setcontroltext(win,Check9, "Hide Drive (I) " +ILAbel) setcontroltext(win,Check10,"Hide Drive (J) " +JLAbel) setcontroltext(win,Check11,"Hide Drive (K) " +KLAbel) setcontroltext(win,Check12,"Hide Drive (L) " +LLAbel) setcontroltext(win,Check13,"Hide Drive (M) " +MLAbel) setcontroltext(win,Check14,"Hide Drive (N) " +NLAbel) setcontroltext(win,Check15,"Hide Drive (O) " +OLAbel) setcontroltext(win,Check16,"Hide Drive (P) " +PLAbel) setcontroltext(win,Check17,"Hide Drive (Q) " +QLAbel) setcontroltext(win,Check18,"Hide Drive (R) " +RLAbel) setcontroltext(win,Check19,"Hide Drive (S) " +SLAbel) setcontroltext(win,Check20,"Hide Drive (T) " +TLAbel) setcontroltext(win,Check21,"Hide Drive (U) " +ULAbel) setcontroltext(win,Check22,"Hide Drive (V) " +VLAbel) setcontroltext(win,Check23,"Hide Drive (W) " +WLAbel) setcontroltext(win,Check24,"Hide Drive (X) " +XLAbel) setcontroltext(win,Check25,"Hide Drive (Y) " +YLAbel) setcontroltext(win,Check26,"Hide Drive (Z) " +ZLAbel) for x = 1 to 26 setstate(win,x,0) next x retval = findPIDByName("explorer.exe") if retval <>0 killProcess(retval) 'Here KillProcess stops an exe OR use GOSUB DOSOMETHINGELSE etc.... ELSE 'print "Process Not Found." ENDIF endif ENDIF CASE BUTTON_3 'Quit IF @NOTIFYCODE = 0 closewindow win end endif ENDSELECT CASE @IDCLOSEWINDOW CLOSEWINDOW win ENDSELECT RETURN 0 ENDSUB '====================================================== ' This code is used for finding and stopping a program. '====================================================== sub findPIDByName(string fileNameToFindPID),int '// required by fined PIDByName const TH32CS_SNAPHEAPLIST =0x00000001 const TH32CS_SNAPPROCESS =0x00000002 const TH32CS_SNAPTHREAD =0x00000004 const TH32CS_SNAPMODULE =0x00000008 const TH32CS_SNAPMODULE32 =0x00000010 const TH32CS_SNAPALL =(TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE) const TH32CS_INHERIT =0x80000000 const PROCESS_ALL_ACCESS =0x1F0FFF type PROCESSENTRY32 uint dwSize uint cntUsage uint th32ProcessID uint th32DefaultHeapID uint th32ModuleID uint cntThreads uint th32ParentProcessID uint pcPriClassBase uint dwFlags istring szExeFile[259] endtype def pe:PROCESSENTRY32 string item,PID DEF retval, x:int x = 0 hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0) pe.dwSize=len(pe) retval=Process32First(hSnapshot,pe) do if LCASE$(pe.szExeFile) = LCASE$(fileNameToFindPID) CloseHandle(hSnapshot) return pe.th32ProcessID ENDIF item = pe.szExeFile PID = STR$(pe.th32ProcessID) print "["+pid+"] "+item x++ dwPriorityClass = 0 hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe.th32ProcessID) if hProcess = NULL print error("Open Process Fail findpidbyname ") else dwPriorityClass = GetPriorityClass(hProcess) if dwPriorityClass <>0 'print dwPriorityClass ELSE 'print error("dwPriorityClass") endif CloseHandle(hProcess) /*' Print process Info print "process ID = ",pe.th32ProcessID print "thread count = ",pe.cntThreads print "parent process ID = ",pe.th32ParentProcessID print "Priority Base = ",pe.pcPriClassBase print "Priority Class = ",dwPriorityClass */ endif pe.dwSize=len(PROCESSENTRY32) retval=Process32Next(hSnapshot,pe) until retval = false CloseHandle(hSnapshot) return 0 ENDSUB sub findProcessIdByName(int processID),INT int ret string szProcessName szProcessName = SPACE$(255) hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE,processID ) if hProcess <>0 ret = EnumProcessModules( hProcess, bProcess[0], len(bProcess), &cbNeeded) if ret <>0 ret = GetModuleBaseName(hProcess, bProcess[0], szProcessName,len(szProcessName)) ' ret = GetModuleFileNameEx(hProcess, bProcess[0], szProcessName,len(szProcessName)) if ret <>0 print szProcessName ELSE print error("GetModule") ENDIF ELSE error("EnumProcessModules") ENDIF CloseHandle( hProcess ) ELSE print error( "Openprocess Failed"+str$(processID)) ENDIF return 0 ENDSUB sub killProcess(int PID) HANDLE hProc hProc = OpenProcess(PROCESS_ALL_ACCESS|PROCESS_TERMINATE, FALSE, PID) if hProc <>0 if TerminateProcess(hProc, 0) <>0 'MessageBox (NULL, "CLOSED", "CLOSED", @MB_ICONSTOP) else MessageBox (NULL, error("SUB KillProcess "), "NOT CLOSED PID"+str$(procId), @MB_ICONSTOP) CloseHandle(hProc) endif else MessageBox (NULL, error("SUB KillProcess "),"I CANT CLOSE "+str$(procId),@MB_ICONSTOP) ENDIF ENDSUB sub SetPrivilege(HANDLE hToken, string lpszPrivilege,INT bEnablePrivilege) 'TYPE TOKEN_PRIVILEGES 'DEF PrivilegeCount:INT 'DEF LowPart:INT 'DEF HighPart:INT 'DEF Attributes:INT 'ENDTYPE def tp:TOKEN_PRIVILEGES def luid:LUID if LookupPrivilegeValue(NULL,lpszPrivilege,&luid ) = 0 error("LookupPrivilegeValue error: ") return FALSE ENDIF tp.PrivilegeCount = 1 tp.Privileges[0].Luid = luid if bEnablePrivilege = true tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED else tp.Privileges[0].Attributes = 0 ENDIF '// Enable the privilege or disable all privileges. if AdjustTokenPrivileges(hToken,FALSE, &tp, LEN(TOKEN_PRIVILEGES), 0, 0) =0 error("AdjustTokenPrivileges error:") return FALSE ENDIF if GetLastError() = ERROR_NOT_ALL_ASSIGNED print "The token does not have the specified privilege." return FALSE ENDIF return TRUE ENDSUB SUB error(string errorCall),string INT CodeErrorId, nBufferSize, flag STRING sBuffer,retError nBufferSize = 1024 sBuffer = String$(nBufferSize, Chr$(0)) flag=FORMAT_MESSAGE_FROM_SYSTEM CodeErrorId=GetLastError() FormatMessage(flag, NULL,CodeErrorId,LANG_NEUTRAL, sBuffer, nBufferSize ,NULL ) retError = errorCall+" / "+sBuffer+" / ErrorID = "+str$(CodeErrorID) return retError endsub sub GetDriveNames() Drive = GetAllDrivesStr() l = len(Drive) for i = 1 to l dir = mid$(Drive,i,1) int DriveType = 0 DriveType = GetDriveTypeFL(dir + ":\\") 'print dir , " ",Drivetype string strdrive = "" strdrive = dir + ":\\" name = "" if((strdrive <> "A:\\") & (strdrive <> "B:\\")) GetVolumeInformationA(strdrive,name,255,serialnumber,maxcomponentlength,flags,filesystemname,255) endif if DriveType = 2 and strdrive = "A:\\" or strdrive = "B:\\" result = RegSetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","Floppy Drive",dir) goto nexti endif if DriveType = 5 then result = RegSetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","CD / DVD Drive",dir) goto nexti endif if((strdrive <> "A:\\") & (strdrive <> "B:\\")) if len(name) = 0 and DriveType = 3 result = RegSetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels","Fixed Drive",dir) else result = RegSetValue("HKEY_CURRENT_USER\\Software\\Andys Hidden Drives\\Labels",name,dir) endif endif label nexti next i return endsub ' GetAllDrivesStr sub GetAllDrivesStr(),string def n, t, s:int def d:string d = "" n = GetLogicalDrivesFL() for t=0 to 25 s = 2 ^ t if (n & s) d += chr$(65 + t) endif next t return d EndSub