Script to hide drive letters in Windows (VBScript)

Introduction

This VBScript sample illustrates how to hide recovery partition or specified partition diskpart(s).

Scenarios

Some organizations want to hide the BCD partition, or the OEM recovery partition.

Script

Step1: Double-click on the script, it will show a Message box to input specified partition letters.

Step2: Enter the partition letter(s), and left click “OK” button. Then it will refresh the windows explorer, and hide the specified partition(s).

Before execute the script

After execute the script

Note:

1. About the input format, you can enter like “d,e” ”d e” “d;e”or anything include letters.

2. If you want to show all hidden partition, you can enter “showall” .Then all partitions will display.

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

VB Script
Edit|Remove
For i = 1To Len(Drive) 
    substr= Mid(Drive,i,1) 
    x = 0For j = Asc("A"To Asc("Z") 
        If Chr(j) = UCase(substr) Then'Varify if  the input letter duplicateIf InStr(Drive,substr) = InStrRev(Drive,substr)  Then'Varify if the specifid letter exists If  fso.DriveExists(substr) Then                          
                        bits = bits + 2^x  
                    Else  
                        wscript.echo "The Drive letter '"&UCase(substr)&"' not exsits!Try again!" 
                        exitcode = 1ExitForEndIfElse  
                wscript.echo "Something dupilcate,please try again" 
                exitcode = 1EndIfEndIf 
        x = x + 1NextIf exitcode = 1ThenExitForEndIfNext

Prerequisite

Windows 7 or higher version

Additional Resources

Related forum threads:

Hiding the recovery partition Diskpart script solution