复制代码
- @echo off
- :inp
- set Drv=
- cls
- echo 输入数字“0”取消隐藏,输入不重复的字母隐藏相应的磁盘。
- set/p Drv=输入磁盘(如:EaF)-
- if "%Drv%"=="" goto :inp
- set "A_Z=A B C D E F G H I J K L N M O P Q R S T U V W X Y Z"
- for /f %%i in ("%Drv%") do call :setv "%%i"
- if %Drv%==0 set TT=00&goto :hidrv
- ::小写换大写
- for %%j in (%A_Z%) do call,set "Drv=%%Drv:%%j=%%j%%"
- ::判断重复
- set ddrv=%Drv%
- set num=
- :rpd
- if #%dDrv%==# goto :rout
- set/a num+=1
- ::判断字符
- call :wrd %ddrv:~0,1%
- if %flag%==0 goto :err
- set dDrvTmp%num%=%ddrv:~0,1%
- set dDrv=%ddrv:~1%
- goto :rpd
- :rout
- setlocal enableDelayedExpansion
- for /l %%c in (1 1 %num%) do (
- set/a nn=%%c+1
- for /l %%d in (!nn! 1 %num%) do (
- if /i !dDrvTmp%%c!==!dDrvTmp%%d! goto :err
- )
- )
- ::按顺序排列
- for /l %%e in (1 1 %num%) do (
- for /l %%f in (1 1 %num%) do (
- if !dDrvTmp%%e! lss !dDrvTmp%%f! (
- set x=!dDrvTmp%%e!
- set dDrvTmp%%e=!dDrvTmp%%f!
- set dDrvTmp%%f=!x!
- )
- )
- )
- for /l %%k in (1 1 %num%) do (
- set DD=!DD!!dDrvTmp%%k!
- )
- ::显示
- set dd=!dd:~-%num%!
- echo 要隐藏的磁盘有%DD%,共[%num%]个盘。
- set n10=
- :MuD
- if #%DD%==# goto :reg16
- set DDTmp=%dD:~0,1%
- set DD=%dD:~1%
- set n=1
- for %%m in (%A_Z%) do (
- call :setn n
- if /i %DDTmp%==%%m call :setn2 n2&goto :outFor
- )
- :outFor
- set/a n10+=%n2%
- goto :MuD
- ::换成十六进制
- :reg16
- call :A %n10%
- ::echo !T3!
- ::注册表二进制数值表达方式
- ::T3换BIN
- set TT=
- :bi
- set/a x+=1
- set Tn=0%T3:~-2%
- set Tn=!Tn:~-2!
- set T3=%T3:~,-2%
- set TT=!TT!!Tn!
- if not #%T3%==# goto :bi
- ::隐藏磁盘
- ::-=核心代码=-
- :hidrv
- set TT=%TT%000000
- echo %TT:~,8%
- reg add HKCU\SoftWare\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoDrives /t REG_BINARY /d %TT:~,8% /f
- echo 结束explorer进程生效。按任意键结束并打开我的电脑查看
- pause>nul
- taskkill /f /im explorer.exe>nul
- endlocal
- start/min "" explorer "%~dp0"
- start explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
- ping n 3 127.1>nul
- goto :eof
- ::调用标签
- :err
- cls&echo 输入格式不正确,或有不允许的字符。
- echo 请重新输入...
- ping n 2 127.1>nul
- goto :inp
- goto :eof
- :wrd
- for %%p in (%A_Z%) do if %1==%%p set flag=1&goto :eof
- set flag=0
- goto :eof
- :setv
- set Drv=%~1
- goto :eof
- :setn
- set/a %1*=2
- goto :eof
- :setn2
- set/a %1=%n%/2
- goto :eof
- :A
- set str=0123456789ABCDEF
- set T1=%1
- SET T3=
- :B
- set/A T2=T1%%16
- SET T2=!str:~%t2%,1!
- SET/A T1=%T1%/16
- SET T3=%T2%%T3%
- IF %T1%==0 GOTO :EOF
- GOTO B
- goto :eof
- exit
- ::========================
- ABCD E F G H I J K L M N O
- 1248 16 32 64 128 256 512 1024 2048 4096 8192 16384
- P Q R S T U V
- 32768 65536 131072 262144 524288 1048576 2097152
- W X Y Z
- 4194304 8388608 16777216 33554432
- ::------------------------
- 输入字母,判断是哪个,计算出十进制数,再换算成十六进制
- 相加,得结果
- 结束explorer进程,再打开我的电脑查看
- ::------------------------
- 系统目录CLSID:
- 网上邻居.{208D2C60-3AEA-1069-A2D7-08002B30309D}
- 我的电脑.{20D04FE0-3AEA-1069-A2D8-08002B30309D}
- 回收站(满).{5ef4af3a-f726-11d0-b8a2-00c04fc309a4}一般无效
- 回收站.{645FF040-5081-101B-9F08-00AA002F954E}
- ::------------------------
- 输入字母,判断是哪个,+[判断重复][转成大写][调整字母顺序],
- 计算出十进制数,再换算成十六进制,+[换成注册表相应的格式],
- 结束explorer进程,再打开我的电脑查看
- ::------------------------
- [如何清空变量]
- [去除一行中重复的字符]
- ::------------------------
- setlocal enableDelayedExpansion
- 开启了变量延迟,如果目录或文件名中含有“!”感叹号,
- 可能会解释成变量识别符号。
- ::------------------------
- REG_BINARY(默认)类型换成REG_DWORD也可以用。
- ::========================
复制代码
- @echo off
- :inp
- cls
- set Drv=
- echo 输入数字“0”取消隐藏,输入若干字母隐藏相应的磁盘。
- set/p Drv=输入磁盘(如:EaF)-
- if "%Drv%"=="" goto :inp
- if %Drv%==0 set TT=00&goto :hidrv
- ::小写换大写顺序输出并剔除重复
- set mat=A B 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 %%d in (%mat%) do (
- call set _%%d=
- )
- :lp
- if not defined _%Drv:~,1% set "_%Drv:~,1%=1"
- set "Drv=%Drv:~1%"
- if defined Drv goto lp
- set n=1
- set n10=
- set Dnum=
- for %%m in (%mat%) do (
- call :setn n
- if defined _%%m (
- call :sshow %%m Drv Dnum n2 n10
- )
- )
- ::显示
- echo.
- echo 要隐藏的磁盘有%Drv%,共[%Dnum%]个盘。
- ::换成十六进制
- :reg16
- setlocal enableDelayedExpansion
- call :A %n10%
- ::注册表二进制数值表达方式
- ::T3换BIN
- set TT=
- :bi
- set/a x+=1
- set Tn=0%T3:~-2%
- set Tn=!Tn:~-2!
- set T3=%T3:~,-2%
- set TT=!TT!!Tn!
- if not #%T3%==# goto :bi
- ::隐藏磁盘
- ::-=核心代码=-
- :hidrv
- set TT=%TT%000000
- reg add HKCU\SoftWare\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoDrives /t REG_BINARY /d %TT:~,8% /f
- echo 结束explorer进程生效。按任意键结束并打开我的电脑查看
- pause>nul
- taskkill /f /im explorer.exe>nul
- endlocal
- start/min "" explorer "%~dp0"
- start explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
- ping -n 3 127.1>nul
- goto :eof
- ::调用标签
- :sshow
- set %2=%Drv%%1
- set/a %3+=1
- set/a %4=n/2
- set/a %5+=n2
- goto :eof
- :setn
- set/a %1*=2
- goto :eof
- :A
- set str=0123456789ABCDEF
- set T1=%1
- SET T3=
- :B
- set/A T2=T1%%16
- SET T2=!str:~%t2%,1!
- SET/A T1=%T1%/16
- SET T3=%T2%%T3%
- IF %T1%==0 GOTO :EOF
- GOTO B
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |