未完成-UsbCheck

2016年1月11日 0 条评论 1.48k 次阅读 0 人点赞
@echo off
title usbcheck
::setlocal enabledelayedexpansion
set tim=3000
reg add HKLM\Software\ubc
for /f "eol=! tokens=2" %%i in ('reg query HKLM\Software\ubc') do set passw=%%i
if "%passw%"=="" goto :first
set passw=%passw:~3%
goto :check

:first
start/w mshta vbscript:msgbox("检测到未有设置过密码!",OK,"移动设备检测程序")(window.close)
call :killusb
call :changepass

:check
devcon findall =usb |find "PID" >nul && (
  set num=3
  goto :found
  )
:tim
start/w mshta "javascript:document.write();setTimeout('close()',%tim%)"
set tim=3000
goto :check

:found
call :kill
winput.exe "$input" "已发现 ' 移动存储 ' 设备,请输入使用密码:" /pass /num >"%temp%\lf"
set passn=
set/p passn=<"%temp%\lf"
del/q "%temp%\lf"
if "%passn%"=="120" goto :changepass
if "%passw%"=="%passn%" (set right=1) else (set right=0)
set/a num-=1
if %num% LSS 1 (
  goto :fall
) else (
  if "%right%"=="1" (
    call :messege1
    goto :OK
  ) else (
    goto :found
  )
)

:OK
winput.exe "$input" "输入密码正确,请输入 ' 移动设备 ' 使用时长(单位:分钟;数值小于1440)" /num >"%temp%\lf"
set tim=
set/p tim=<"%temp%\lf"
del/q "%temp%\lf"
if "%tim%"=="" goto :OK
if %tim% GTR 1441 goto :OK
set tim=%tim%*60000
start explorer.exe
goto :tim

:kill
taskkill /f /im explorer.exe >nul 2>nul
goto :eof

:killusb
call :kill
for /f %%i in ('devcon findall ^=usb ^|find "USBSTOR"') do devcon remove "@%%i"
call :kill
for /f %%i in ('devcon findall usb* ^|find "USBSTOR"') do devcon remove "@%%i"
call :kill
for /f %%i in ('devcon findall ^=usb ^|find "PID"') do devcon remove "@%%i"
goto :eof
::devcon rescan

:messege1
start/w mshta vbscript:msgbox("密码正确!  (提示:输入120进入修改密码)",OK,"移动设备检测程序")(window.close)
goto :eof

:changepass
winput.exe "$input" "请输入新的使用密码:" /pass /num >"%temp%\lf"
set passn1=
set/p passn1=<"%temp%\lf"
del/q "%temp%\lf"
winput.exe "$input" "请再次输入新的使用密码:" /pass /num >"%temp%\lf"
set passn2=
set/p passn2=<"%temp%\lf"
del/q "%temp%\lf"
if "%passn1%" NEQ "%passn2%" goto :changepass
if "%passn1%"=="" goto :changepass
reg add HKLM\Software\ubc /ve /t REG_SZ /d %passn1% /f
goto :found

:fall
call :killusb
call :killusb
start/w mshta vbscript:msgbox("三次密码输入均错误!将不能使用移动设备!",OK,"移动设备检测程序")(window.close)
start/w mshta vbscript:msgbox("可以再次将移动设备连接到本电脑以尝试密码",OK,"移动设备检测程序")(window.close)
start explorer.exe
goto :check

:prossce
tasklist /fi "IMAGENAME eq spoolsv.exe" |find /i "spoolsv.exe"

Sevenfal

这个人太懒什么东西都没留下

文章评论(0)