功能:隐藏和恢复 磁盘,光盘,移动磁盘。
有密码保护。
说明:基于mountvol,对批处理有点了解的都可以解开。
我只是把它完善成一个傻瓜版的工具,因为有密码设置,转成exe后可供一般用户使用。(附件已传exe版)
如发现bug请跟帖提出,谢谢。- @echo off&setlocal enabledelayedexpansion
- title Code By wankoilz 2010/4/17 @Win7 Q375913828
- mode con cols=60 lines=20
- set type2=移动磁盘
- set type3=本地磁盘
- set type5=光盘驱动
- set logo=:::::::::::::::::::欢迎来到批处理的世界:::::::::::::::::::
- :::::::::::::::::密码:::::::::::::::::::::::::::::::::::::::::::::::
- set "cmd=echo.&set/p=........<nul"
- :pass
- cls
- echo;
- echo;
- for /l %%i in (0,1,48) do (set/p=!logo:~%%i,1!<nul&for /l %%i in (1,1,25) do echo.>nul)
- echo;
- echo;
- echo ╔-------------------------------------------╗
- echo ┆ 密码设置: ┆
- echo ┆ 初始密码 xl,输入ccc可以进行密码修改 ┆
- echo ╚-------------------------------------------╝
- reg query hkcu\pass >nul 2>nul||reg add hkcu\pass /v pass /t reg_sz /d "xl" /f >nul
- for /f "skip=2 tokens=3" %%i in ('reg query hkcu\pass') do set "originalpass=%%i"
- %cmd%&set/p pass=输入密码:
- if /i "!pass!"=="ccc" (
- %cmd%&set/p pass=输入旧密码:
- if "!pass!"=="!originalpass!" (
- %cmd%&set/p newpass=正确,输入新密码:
- reg add hkcu\pass /v pass /t reg_sz /d "!newpass!" /f >nul&%cmd%&set/p=密码修改成功,<nul&pause
- ) else (%cmd%&set/p=密码错误!&goto :pass)
- ) else (if not "!pass!"=="!originalpass!" (echo ........密码不对...&pause&goto :pass) )
-
- ::::::::::::::::::获取当前存在的逻辑盘:::::::::::::::::::::::::::::::
- :begin
- set n=0&set c=0
- for /f "skip=1 tokens=1,2" %%i in ('wmic logicaldisk get name^,drivetype') do (
- if not "%%j"=="" (set/a n+=1&set disk!n!=%%j&set %%j=%%i
- )
- )
- :::::::::::::::::::更新列表:::::::::::::::::::::::::::::::::::::::::::
- reg query hkcu\volume >nul 2>nul&&call :addtable||call :gettable
- ::::::::::::::::::::交互界面::::::::::::::::::::::::::::::::::::::::::
- for /f "skip=2 tokens=1" %%i in ('reg query hkcu\volume') do set/a c+=1
- set/a line=%c%+15
- mode con cols=60 lines=%line%
- :list
- cls&set x=0
- echo;
- echo ╔-------------------------------------------╗
- echo ┆ 热情欢迎您加入批处理之家: bbs.bathome.cn ┆
- echo ┆ 注意:①隐藏系统盘会致系统崩溃,重启可恢复 ┆
- echo ┆ ②隐藏脚本所在盘会导致脚本被强行关闭 ┆
- echo ┆ ③r--刷新列表(有时候移动磁盘已经拔除 ┆
- echo ┆ 但列表上仍有显示,r可以将其从列表中 ┆
- echo ┆ 删除),同时还将恢复所有已隐藏磁盘 ┆
- echo ╚-------------------------------------------╝
- echo ╔-------------------------------------------╗
- for /f "skip=2 tokens=1,3,4,5" %%i in ('reg query hkcu\volume') do (
- set/a x+=1&set _disk!x!=%%i&set _type!x!=%%j&set _flag!x!=%%k&set _vol!x!=%%l
- set x= !x!&echo ┆ !x:~-2!........%%i %%j%%k ┆
- )
- echo ╚-------------------------------------------╝
- echo;
- set/p=......<nul&set selectnum=&set/p selectnum=选择要隐藏(或显示)的磁盘对应数字(q退出,r刷新):
- :::::::::::::::::::::::::::::判断输入是否合法:::::::::::::::::::::::::::::::
- if /i "%selectnum%"=="q" exit
- if /i "%selectnum%"=="r" goto :refreshtable
- set flag=&for /l %%i in (1,1,%x%) do if "%selectnum%"=="%%i" set flag=ok
- if not defined flag (echo 非法输入!&pause&goto :list)
- ::::::::::::::::::::::::::::::核心代码(装载或卸载卷标)::::::::::::::::::::
- if "!_flag%selectnum%!"=="(未隐藏)" (
- call :show-or-hide !_disk%selectnum%! !_type%selectnum%! ^(已隐藏^) !_vol%selectnum%! "mountvol !_disk%selectnum%! /d"
- ) else (
- call :show-or-hide !_disk%selectnum%! !_type%selectnum%! ^(未隐藏^) !_vol%selectnum%! "mountvol !_disk%selectnum%! !_vol%selectnum%!"
- )
- goto :list
- rem 首次运行添加磁盘列表到注册表
- :gettable
- for /l %%i in (1,1,%n%) do (
- for /f "delims=" %%j in ('mountvol !disk%%i! /l') do (
- call call reg add hkcu\volume /v !disk%%i! /t reg_sz /d "%%%%type%%!disk%%i!%%%%%% (未隐藏) %%j\" /f >nul
- ))
- goto :eof
- rem 启动(刷新)时如果有新盘符出现就添加到列表
- :addtable
- for /f "skip=2 tokens=1" %%i in ('reg query hkcu\volume') do set _%%i=ok
- for /l %%i in (1,1,%n%) do (
- if not defined _!disk%%i! (
- for /f "delims=" %%j in ('mountvol !disk%%i! /l') do (
- call call reg add hkcu\volume /v !disk%%i! /t reg_sz /d "%%%%type%%!disk%%i!%%%%%% (未隐藏) %%j\" /f >nul
- )))
- goto :eof
- rem 显示(隐藏)磁盘
- :show-or-hide diskname disktype flag vol command
- %~5
- reg delete hkcu\volume /v %1 /f >nul
- reg add hkcu\volume /v %1 /t reg_sz /d "%2 %3 %4\" /f >nul
- goto :eof
- rem 刷新列表--删除不存在的盘符,以及装载所有卷标以显示所有盘符
- :refreshtable
- echo .......刷新列表中...
- setlocal
- :loop
- set a=0
- for /f %%i in ('mountvol') do (
- set "str=%%i"
- if "!str:~0,3!"=="\\?" set flag2=ok
- if defined flag2 (
- set/a a+=1,b=a%%2
- if !b! equ 1 set "vol=%%i"
- if !b! equ 0 (
- set "%%i=ok"
- if "%%i"=="***" (
- for %%j in (c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) do (
- if not defined %%j:\ (mountvol %%j: !vol! >nul&goto :loop)
- )))))
- reg delete hkcu\volume /f >nul 2>nul&endlocal&goto :begin
- :eof
复制代码 链接: https://pan.baidu.com/s/1hi18zMeZ9bw6-LoNjHxUjg 提取码: s85y |