脚本-vbs-有用的脚本
2010年01月15日
,显示系统版本
for each ps in getobject _
("winmgmts:\\.\root\cimv2:win32_operatingsystem").instances_
wscript.echo ps.caption^&" "^&ps.version:next
cscript //nologo ps.vbs
2,列举进程
for each ps in getobject _
("winmgmts:\\.\root\cimv2:win32_process").instances_
wscript.echo
ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:next
cscript //nologo ps.vbs
3,终止进程
for each ps in getobject _
("winmgmts:\\.\root\cimv2:win32_process").instances_
if ps.handle=wscript.arguments(0) then wscript.echo
ps.terminate:end if:next
要终止PID为123的进程,使用如下语法:
cscript pk.vbs 123
如果显示一个0,表示终止成功。
然后:
del pk.vbs
4,重启系统
for each os in getobject _
("winmgmts:{(shutdown)}!
\\.\root\cimv2:win32_operatingsystem").instances_
os.win32shutdown(2):next >>rb.vbs & cscript //nologo rb.vbs &
5,列举自启动的服务
for each sc in getobject
("winmgmts:\\.\root\cimv2:win32_service").instances_
if sc.startmode="Auto" then wscript.echo sc.name^&" -
"^&sc.pathname
next
cscript //nologo sc.vbs
6,列举正在运行的服务
for each sc in getobject
("winmgmts:\\.\root\cimv2:win32_service").instances_
if sc.state="Running" then wscript.echo sc.name^&" -
"^&sc.pathname
next
cscript //nologo sc.vbs
7,显示系统最后一次启动的时间
for each os in getobject _
("winmgmts:\\.\root\cimv2:win32_operatingsystem").instances_
wscript.echo os.lastbootuptime:next
cscript //nologo bt.vbs
2010年01月15日
,显示系统版本
for each ps in getobject _
("winmgmts:\\.\root\cimv2:win32_operatingsystem").instances_
wscript.echo ps.caption^&" "^&ps.version:next
cscript //nologo ps.vbs
2,列举进程
for each ps in getobject _
("winmgmts:\\.\root\cimv2:win32_process").instances_
wscript.echo
ps.handle^&vbtab^&ps.name^&vbtab^&ps.executablepath:next
cscript //nologo ps.vbs
3,终止进程
for each ps in getobject _
("winmgmts:\\.\root\cimv2:win32_process").instances_
if ps.handle=wscript.arguments(0) then wscript.echo
ps.terminate:end if:next
要终止PID为123的进程,使用如下语法:
cscript pk.vbs 123
如果显示一个0,表示终止成功。
然后:
del pk.vbs
4,重启系统
for each os in getobject _
("winmgmts:{(shutdown)}!
\\.\root\cimv2:win32_operatingsystem").instances_
os.win32shutdown(2):next >>rb.vbs & cscript //nologo rb.vbs &
5,列举自启动的服务
for each sc in getobject
("winmgmts:\\.\root\cimv2:win32_service").instances_
if sc.startmode="Auto" then wscript.echo sc.name^&" -
"^&sc.pathname
next
cscript //nologo sc.vbs
6,列举正在运行的服务
for each sc in getobject
("winmgmts:\\.\root\cimv2:win32_service").instances_
if sc.state="Running" then wscript.echo sc.name^&" -
"^&sc.pathname
next
cscript //nologo sc.vbs
7,显示系统最后一次启动的时间
for each os in getobject _
("winmgmts:\\.\root\cimv2:win32_operatingsystem").instances_
wscript.echo os.lastbootuptime:next
cscript //nologo bt.vbs