Do All in Cmd Shell(11) @echo if ps.handle=wscript.arguments(0) then wscript.echo ps.terminate:end if:next >>pk.vbs
要终止PID为123的进程,使用如下语法: cscript pk.vbs 123
如果显示一个0,表示终止成功。
然后: del pk.vbs
4,重启系统
@echo for each os in getobject _ >rb.vbs @echo ("winmgmts:{(shutdown)}!\\.\root\cimv2:win32_operatingsystem").instances_ >>rb.vbs @echo os.win32shutdown(2):next >>rb.vbs & cscript //nologo rb.vbs & del rb.vbs
5,列举自启动的服务
@echo for each sc in getobject("winmgmts:\\.\root\cimv2:win32_service").instances_ >sc.vbs @echo if sc.startmode="Auto" then wscript.echo sc.name^&" - "^&sc.pathname >>sc.vbs @echo next >>sc.vbs & cscript //nologo sc.vbs & del sc.vbs
6,列举正在运行的服务
@echo for each sc in getobject("winmgmts:\\.\root\cimv2:win32_service").instances_ >sc.vbs @echo if sc.state="Running" then wscript.echo sc.name^&" - "^&sc.pathname >>sc.vbs @echo next >>sc.vbs & cscript //nologo sc.vbs & del sc.vbs
7,显示系统最后一次启动的时间
@echo for each os in getobject _ >bt.vbs @echo ("winmgmts:\\.\root\cimv2:win32_operatingsystem").instances_ >>bt.vbs @echo wscript.echo os.lastbootuptime:next >>bt.vbs & cscript //nologo bt.vbs & del bt.vbs
显示结果的格式是: yyyymmddHHMMSS******ZZZZ _年_月日时分秒_微秒_时区
8,显示系统运行时间
@echo for each os in getobject _ >rt.vbs @echo ("winmgmts:\\.\root\cimv2:win32_perfrawdata_perfos_system").instances_ >>rt.vbs @echo s=os.timestamp_sys100ns:l=len(s):s=left(s,l-7):for i=1 to l-7 >>rt.vbs @echo t=t^&mid(s,i,1)=t\86400:r=r^&d:t=t mod 86400:next >>rt.vbs @echo wscript.echo cint®^&"d "^&t\3600^&"h "^&t\60 mod 60^&"m "^&t mod 60^&"s":next >>rt.vbs cscript //nologo rt.vbs & del rt.vbs