以前有保存一份批处理 可禁用或隐藏指定分区,运行完了需要注销或重启也可以在返回里面加入一条自动重启explorer的命令
taskkill /f /im explorer.exe & start explorer
@echo off
mode con cols=45 lines=13
echo.
title 禁用或隐藏任意分区
set l1= 如果需要继续其他操作请选择y
set l2= 按任意键退出,感谢使用!
:main
cls
color 0c
echo.
echo 隐藏或禁用任意分区
echo.
echo.
echo 1. 禁用任意分区
echo 2. 解除禁用任意分区
echo 3. 隐藏任意分区
echo 4. 解除隐藏任意分区
echo 5. 按任意键退出
echo.
SET verybat=
SET /P verybat= 请选择要进行的操作:
IF /I '%verybat:~0,1%'=='1' GOTO 1
IF /I '%verybat:~0,1%'=='2' GOTO 2
IF /I '%verybat:~0,1%'=='3' GOTO 3
IF /I '%verybat:~0,1%'=='4' GOTO 4
exit
:1
cls
color 4f
set regadd=reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
echo.&echo.&echo.&echo.
set /p dirv1= 请选择你要禁用的分区:
set num=2
set str=c d e f g h i j k l m n o p q r s t u v w x y z
for %%i in (%str%) do (
set /a num*=2
if /i "%%i"=="%dirv1%" goto forbid
)
:forbid
%regadd% /v NoViewOnDrive /t REG_DWORD /d %num% /f
gpupdate.exe /force >nul
cls
echo.
echo 已成功禁用了"%dirv1%:"分区
echo. && echo %l1% && echo. && echo %l2% && echo.
set jx=
set /p jx= 请选择:
if /i "%jx%"=="y" goto main
exit
:2
reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoViewOnDrive /f >nul 2>nul
gpupdate /force >nul
cls
color 2f
echo.
echo 已成功解除任意分区的禁用。
echo. && echo %l1% && echo. && echo %l2% && echo.
set jx=
set /p jx= 请选择:
if /i "%jx%"=="y" goto main
exit
:3
set regadd=reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
cls
color f9
echo.&echo.&echo.&echo.
set /p dirv2= 请选择你要隐藏的分区:
set num=2
set str=c d e f g h i j k l m n o p q r s t u v w x y z
for %%i in (%str%) do (
set /a num*=2
if /i "%%i"=="%dirv2%" goto hide
)
:hide
%regadd% /v NoDrives /t REG_DWORD /d %num% /f
gpupdate /force >nul
cls
color f5
echo.
echo 已成功隐藏了"%dirv2%:"分区
echo. && echo %l1% && echo. && echo %l2% && echo.
set jx2=
set /p jx2= 请选择:
if /i "%jx2%"=="y" goto main
exit
:4
cls
color 1f
reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoDrives /f >nul 2>nul
gpupdate /force >nul
echo.
echo 已成功解除任意分区的隐藏。
echo. && echo %l1% && echo. && echo %l2% && echo.
set jx2=
set /p jx2= 请选择:
if /i "%jx2%"=="y" goto main
exit
试一试:复制一个 pecmd.exe 到批处理目录,修改一下下面的bat(这个是对移动硬盘的,所以需要修改)
::【隐藏-显示 移动硬盘 隐藏分区】 @echo Off
COLOR 2F
Set Prog= 移动硬盘
Set L1= ╭══════════════════╮
Set L2= ║ ║
Set L3= ╭══┤ %Prog% ├══╮
Set L4= ║ ║ ║ ║
Set L5= ║ ╰══════════════════╯ ║
Set L6= ║ ║
Set L7= ╰════════════════════════╯
Title %Prog%
:A
CLS
Title %Prog%——————显示隐藏分区、隐藏隐藏分区
Echo.
Echo %L1%
Echo %L2%
Echo %L3%
Echo %L4%
Echo %L5%
Echo %L6%
Echo ║ [1] 显示移动硬盘隐藏分区 ║
Echo %L6%
Echo ║ [2] 隐藏移动硬盘隐藏分区 ║
Echo ║ ║
Echo %L7%
Echo.
Set Choice=
Set /P Choice= 请选择要进行的操作 (1/2) ,然后按回车(两次):
If "%Choice%"=="" Goto :A
If Not "%Choice%"=="" Set Choice=%Choice:~0,1%
If /I "%Choice%"=="1" Goto :B
If /I "%Choice%"=="2" Goto :C
Goto :A