We help IT Professionals succeed at work.

Disabling Dives like A:, B: C: or D:

rinosh
rinosh asked
on
How to disable drives through programming? What I need exactly is I just want to disable my A:, C: and D: drives using a VB program.

Thanks!
Rinosh


Comment
Watch Question

Ark
CERTIFIED EXPERT

Commented:
CERTIFIED EXPERT
Commented:
Hi

Private Sub HideDrive(ParamArray sDrives())
    Dim wshShell As Object
    Dim nDrives As Long
    Set wshShell = CreateObject("WScript.Shell")
    For i = 0 To UBound(sDrives)
        nDrives = nDrives + 2 ^ (Asc(UCase(sDrives(i))) - Asc("A"))
    Next i
    wshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDrives", CLng(nDrives), "REG_BINARY"
    Set wshShell = Nothing
End Sub

Private Sub Command1_Click()
    HideDrive "a", "b", "c", "d", "e"
End Sub

'Note: you have to reboot after this to hide drives

Author

Commented:
Hi Ark!

Thanks a lot, as it worked pretty well I don't want u to lose ur points.

Keep up the good work.

Rinosh
Ark
CERTIFIED EXPERT

Commented:
Thanks for points, glad I could help you.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.