一键删除USB 设备 一键卸载USB 设备 自动卸载usb 关机前卸载_knockin' ...
来源:百度文库 编辑:神马文学网 时间:2024/04/26 07:23:50
安全删除闪存只须一键
当闪存、MP3、移动硬盘等一系列USB设备插在电脑上,如果在读写文件的时候,直接拔下的话,突然的断电很有可能造成数据存储出错,甚至烧坏USB设备。为了保证USB设备的安全,我们通常会通过点击Windows任务栏右下角的“安全删除硬件”的图标,然后进行一系列操作来提高安全性。不过采用这种方式速度较慢,而且如果电脑插接了多个USB设备,那么在“安全删除硬件”界面中,就不容易选中我们要删除的闪存,现在我们可以通过一款名为USBDEVIEW的免费小软件,来轻松实现闪存等USB设备的一键删除。1.罗列USB设备
首先在网上下载USBDEVIEW,这个软件包有三个文件,其中有两个是说明文档,而USBDEVIEW程序本身仅有“USBDEVIEW.exe”一个小文件。它不需要安装,直接点击就可以使用。点击USBDEVIEW.exe会出现一个界面(如图1),它可以列出当前连接到电脑上或者曾经连接到电脑上的所有USB设备,包括设备的名称和描述、连接情况、设备类型、序列号、设备添加的日期、最后连接的日期、端口号以及其他信息,用户可以选择断开或者连接列表中的任何设备。在这里需要将经常插接的闪存名称或序列号复制下来(如图2)。
图1
图2
2.编辑批处理文件USBDEVIEW的便捷之处在于可以使用批处理文件自动执行任务。在USBDEVIEW.exe文件所在目录建立一个后缀为.bat的文件,用“记事本”编辑该文件的内容为USBDEVIEW.exe /stop “Ramaxel FlashDisk USB Device”(如图3),在这里将前面复制下来的闪存名称或序列号粘贴进去,内容可根据需要自已设定。如果用户使用的是“Kingston DataTraveler 2.0”闪存,就可以写为USBDEVIEW.exe /stop “DataTraveler”。保存该文件后,可以为它创建桌面快捷方式,这样只要点击一下这个快捷方式的图标就可以迅速完成闪存的“安全删除硬件”。
图3
3.常用参数使用
USBDEVIEW支持几乎所有的USB设备,比如取下USB外置刻录机之前可以执行USBDEVIEW.exe /stop /showmsg “DVD RW”,“/showmsg”是有提示信息的参数。USBDEVIEW还可以看到局域网内的其他电脑上USB设备的连接情况,并对它们进行控制。编辑批处理文件内容为USBDEVIEW.exe /stop “DataTraveler” \\pc02,“pc02”为远程电脑名。
如用户有多个闪存,可以分别建立多个批处理文件,虽然“USBDEVIEW.exe /stop_all”的参数可以一键删除所有的USB设备,但是这样一来就会将连接在该电脑上正在使用中的USB键盘、鼠标、摄像头一起删除,因此不建议用户使用这个参数。
WEEEEEEE############################
如果你要常常操纵U盘,又会忘记拔走,那你可以操纵挑示电脑闭机时主动卸载U盘!是否常常在网吧上钩下机时却忘了带走你心爱的U盘呢!下面知照你让你按次挑示你主动卸载U盘吧!
第一步:结果在记事本按次中输进以下里容:
Onerrorresumenext
Dimfso,d,dc,f
Setfos=CreateObject(“Scripting.FileSystemObject”)
Setdc=fso,Drives
ForEachdindc
Setf=fso.GetFile(d&”\请带我回家.txt”)
Ifleft(f,2)=dthenmsgbox“我是您的:”&d&”盘,请带我回家!”,vbcritical,”主人:您好!”
Next输进好后,把文件保存在C盘根眼次下,并取名为USBDISK..vbs.
第二步:孤击通首—运动,输进gpedit.msc,按回车键,打通组战术编辑器。依次打通策划机配置装备摆设—Windows配置—足本(启动/闭机),双击打通闭机项,再点击增增,选择增增前方保存在C盘的USBDISK..vbs文件,确定撤除出组战术编辑器。
第三步:在需要闭机时随身带走你的U盘或移动硬盘的要眼次中,成立一个文件名为请带我回家.txt的文本文件。以后,如果你闭机时没有拔出U盘或移动硬盘,体例就会弹出告诫框挑示你了!怎么样,很简孤吧,碰运气!
########
USBDeview.exe /stop "Hitachi"
"Hitachi" = PARTIAL DEVICE NAME OR DESCRIPTION
Port_#0006.Hub_#0008 Hitachi HTS545025B9A300 USB Device Mass Storage
USBDeview v1.75
Copyright (c) 2006 - 2010 Nir Sofer
Web Site: http://www.nirsoft.net
将此一行代码保存为taskkill.bat即可:
tasklist | find /v "taskkill.exe" >> %temp%\taskmgr.txt & for /f "skip=4 tokens=2 delims= " %%i in (%temp%\taskmgr.txt) do taskkill /PID %%i
这就个简单思路,多个进程也就过滤一下PID值就行了,而且想要强力关闭,也可以换用ntsd命令
结束你想保留的几个进程以外的所有进程的批处理
来自我自己的博客:http://hi.baidu.com/%B7%C9%C1%FA%B6%CF%D1%A9
无聊,写了个垃圾批处理,可以用来结束你想保留的几个进程以外的所有进程。标准的CUI命令输出,配有标准帮助信息,放入%Systemroot%\system32文件夹中完全可以当作一条外部命令。
将以下代码保存为getask.bat
@echo off
if "%1"=="" goto :error
if "%1"=="/?" goto :help
del /f /q /a %temp%\*.txt 2> nul
for /f "skip=5 tokens=1 delims= " %%i in ('tasklist') do (>>%temp%\task.txt echo %%i)
type %temp%\task.txt|find /v /i "cmd.exe" > %temp%\task0.txt
type %temp%\task0.txt|find /v /i "tasklist.exe" > %temp%\task.txt
type %temp%\task.txt|find /v /i "csrss.exe" > %temp%\task0.txt
set /a NO.1=0
set /a NO.2=1
:begin
if "%1"=="" goto :next
if "%1"==".EXE" goto :error
if "%1"==".exe" goto :error
if "%1"=="/I" goto :important
if "%1"=="/i" goto :important
if "%1"=="/S" goto :secondary
if "%1"=="/s" goto :secondary
set name=%1
set research=%name:~-4%
if not %research%==.exe goto :error
type %temp%\task%NO.1%.txt|find /v /i "%1" > %temp%\task%NO.2%.txt
set /a NO.1=NO.1+1
set /a NO.2=NO.2+1
shift
goto :begin
:next
for /f %%i in (%temp%\task%NO.1%.txt) do (ntsd -c q -pn %%i)
goto :success
:important
type %temp%\task%NO.1%.txt|find /v /i "smss.exe" > %temp%\mustone.txt
type %temp%\mustone.txt|find /v /i "winlogon.exe" > %temp%\musttwo.txt
type %temp%\musttwo.txt|find /v /i "lsass.exe" > %temp%\mustthree.txt
type %temp%\mustthree.txt|find /v /i "svchost.exe" > %temp%\mustfour.txt
type %temp%\mustfour.txt|find /v /i "services.exe" > %temp%\task%NO.1%.txt
shift
goto :begin
:secondary
type %temp%\task%NO.1%.txt|find /v /i "internat.exe" > %temp%\minorone.txt
type %temp%\minorone.txt|find /v /i "explorer.exe" > %temp%\minortwo.txt
type %temp%\minortwo.txt|find /v /i "iexplore.exe" > %temp%\task%NO.1%.txt
shift
goto :begin
:help
echo GETASK [/I] [/S] {[imagename1] [imagename2] [+...]}
echo 描述:
echo 这个命令行工具可用来结束指定进程以外所有进程。
echo.
echo 参数列表:
echo /I 保留系统正常运行必备进程。
echo /S 保留系统基本辅助程序。
echo.
echo 例如:
echo GETASK /I 结束系统必备进程外所有进程。
echo GETASK /I /S 结束系统基本进程外所有进程。
echo GETASK notepad.exe taskmgr.exe 结束notepad.exe和taskmgr.exe以外所有进程。
echo GETASK /I /S notepad.exe 结束系统基本进程和notepad.exe外所有进程。
goto end
:success
del /f /q /a %temp%\*.txt 2> nul
echo 命令成功完成。
goto end
:error
del /f /q /a %temp%\*.txt 2> nul
echo 错误:无效语法。
echo 有关用法,请键入"getask /?"。
:end
用法:getask /i /s 要保留的进程1 要保留的进程2 . .. 要保留的进程N
/i /s 是两个内置参数,有关用法,请键入"getask /?"。
不过毕竟是批处理,对双进程保护毫无办法,而且ntsd命令稍有差池就会错误,对此我已经进行了非常严格的字符过滤,但是仍然个别情况会出现错误。
PS:不要问我为什么用这么多临时文件,想少用几个你自己可以试试...(type命令数据显示后内存...)
########################
想用一条命令关闭除csrss.exe、explorer.exe、lsass.exe、smss.exe、services.exe、svchost.exe、winlogon.exe、system、System Idle Process的所有进程,但我自己搞了很多次都不成功。最好是用一条长命令实现, ...
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" _
- & strComputer & "\root\cimv2")
- Set colProcess = objWMIService.ExecQuery _
- ("Select * from Win32_Process " )
- For Each objProcess In colProcess
- Select Case objProcess.caption
- Case "csrss.exe"
- Case "explorer.exe"
- Case "lsass.exe"
- Case "smss.exe"
- Case "services.exe"
- Case "svchost.exe"
- Case "winlogon.exe"
- Case "system System Idle Process"
- Case Else
- objProcess.Terminate()
- End Select
- Next
- ###############
- http://www.sharecenter.net/thread-175013-1-1.html
-
do all in cmd shell
下面是Process.ini,里面存放不需要结束的进程名,不区分大小写,可自行配置:
4 _) ~' F* O, A9 M% w 5 k9 X) p Z8 S' ]) J" q. c4 ^% {/ N
csrss.exe+ Q) Y" A0 k# d+ O
explorer.exe6 k; ~% {" d; k1 d5 j8 f/ `7 _
lsass.exe
4 d6 B& D, Q" y0 F. {smss.exe
* r9 @$ E X9 eservices.exe
]: l6 @) m8 ?" j4 c8 d) Osvchost.exe
o8 F+ }8 N4 s" A r6 r+ J2 [. y Awinlogon.exe
; V$ y) H" M' K7 e1 w) k& ^System7 Y+ g' ]; h; B+ b$ N
System Idle Process+ N) I' \4 u5 A0 H- y% T
2 C$ @% M F' a运行下面的批处理即可:) _8 g' c) {$ {2 \7 v8 m
- @echo off&Setlocal EnableDelayedExpansion
- rem Code by lxmxn # bbs.cn-dos.net
- for /f "tokens=1 delims=," %%a in ('tasklist /nh /FO CSV') do (
- for /f "delims=" %%b in (Process.ini) do (
- set /a flag+=1
- if /i not %%a=="%%b" set /a num+=1
- )
- if !flag! equ !num! taskkill /f /im %%a
- set /a flag=num=0
- )
- echo the end...
- #############
-
结束你想保留的几个进程以外的所有进程的批处理
来自我自己的博客:http://hi.baidu.com/%B7%C9%C1%FA%B6%CF%D1%A9
无聊,写了个垃圾批处理,可以用来结束你想保留的几个进程以外的所有进程。标准的CUI命令输出,配有标准帮助信息,放入%Systemroot%\system32文件夹中完全可以当作一条外部命令。
将以下代码保存为getask.bat
@echo off
if "%1"=="" goto :error
if "%1"=="/?" goto :help
del /f /q /a %temp%\*.txt 2> nul
for /f "skip=5 tokens=1 delims= " %%i in ('tasklist') do (>>%temp%\task.txt echo %%i)
type %temp%\task.txt|find /v /i "cmd.exe" > %temp%\task0.txt
type %temp%\task0.txt|find /v /i "tasklist.exe" > %temp%\task.txt
type %temp%\task.txt|find /v /i "csrss.exe" > %temp%\task0.txt
set /a NO.1=0
set /a NO.2=1
:begin
if "%1"=="" goto :next
if "%1"==".EXE" goto :error
if "%1"==".exe" goto :error
if "%1"=="/I" goto :important
if "%1"=="/i" goto :important
if "%1"=="/S" goto :secondary
if "%1"=="/s" goto :secondary
set name=%1
set research=%name:~-4%
if not %research%==.exe goto :error
type %temp%\task%NO.1%.txt|find /v /i "%1" > %temp%\task%NO.2%.txt
set /a NO.1=NO.1+1
set /a NO.2=NO.2+1
shift
goto :begin
:next
for /f %%i in (%temp%\task%NO.1%.txt) do (ntsd -c q -pn %%i)
goto :success
:important
type %temp%\task%NO.1%.txt|find /v /i "smss.exe" > %temp%\mustone.txt
type %temp%\mustone.txt|find /v /i "winlogon.exe" > %temp%\musttwo.txt
type %temp%\musttwo.txt|find /v /i "lsass.exe" > %temp%\mustthree.txt
type %temp%\mustthree.txt|find /v /i "svchost.exe" > %temp%\mustfour.txt
type %temp%\mustfour.txt|find /v /i "services.exe" > %temp%\task%NO.1%.txt
shift
goto :begin
:secondary
type %temp%\task%NO.1%.txt|find /v /i "internat.exe" > %temp%\minorone.txt
type %temp%\minorone.txt|find /v /i "explorer.exe" > %temp%\minortwo.txt
type %temp%\minortwo.txt|find /v /i "iexplore.exe" > %temp%\task%NO.1%.txt
shift
goto :begin
:help
echo GETASK [/I] [/S] {[imagename1] [imagename2] [+...]}
echo 描述:
echo 这个命令行工具可用来结束指定进程以外所有进程。
echo.
echo 参数列表:
echo /I 保留系统正常运行必备进程。
echo /S 保留系统基本辅助程序。
echo.
echo 例如:
echo GETASK /I 结束系统必备进程外所有进程。
echo GETASK /I /S 结束系统基本进程外所有进程。
echo GETASK notepad.exe taskmgr.exe 结束notepad.exe和taskmgr.exe以外所有进程。
echo GETASK /I /S notepad.exe 结束系统基本进程和notepad.exe外所有进程。
goto end
:success
del /f /q /a %temp%\*.txt 2> nul
echo 命令成功完成。
goto end
:error
del /f /q /a %temp%\*.txt 2> nul
echo 错误:无效语法。
echo 有关用法,请键入"getask /?"。
:end
用法:getask /i /s 要保留的进程1 要保留的进程2 . .. 要保留的进程N
/i /s 是两个内置参数,有关用法,请键入"getask /?"。
不过毕竟是批处理,对双进程保护毫无办法,而且ntsd命令稍有差池就会错误,对此我已经进行了非常严格的字符过滤,但是仍然个别情况会出现错误。
PS:不要问我为什么用这么多临时文件,想少用几个你自己可以试试...(type命令数据显示后内存...)