[zt] Windows script

xiaoxiao2021-03-06  38

Many things have been made very concise with scripts. Here is a few echo version of several common scripts.

1, display system version

@echo for easy ps in getObject_> ps.vbs@echo ("Winmgmts: //./root/cimv2: win32_operatingsystem") .instances_ >> ps.vbs@echo wscript.echo ps.caption ^ & "^ & PS .version: Next >> Ps.vbscscript // NOLOGO PS.VBS & DEL PS.VBS

2, listed processes

@echo for each ps in getObject_> ps.vbs@echo ("Winmgmts: //./root/cimv2: win32_process")) .instances_ >> ps.vbs@echo wscript.echo ps.handle ^ & vbtab ^ & ps.name ^ & vbtab ^ & ps.executablepath: Next >> ps.vbscript // NOLOGO PS.VBS & DEL PS.VBS

3, termination process

@echo for each ps in getObject_> pk.vbs@echo ("Winmgmts: //./root/cimv2: win32_process") .instances_ >> pk.vbs@echo if ps.handle = wscript.arguments (0) THEN WScript.echo Ps.Terminate: end if: next >> PK.vbs

To terminate the PID 123, use the following title: CScript PK.vbs 123

If a 0 is displayed, it means that the end is successful.

Then: Del Pk.vbs

4, restart the system

@echo for easy 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, list self-starting services

@echo for each sc in getObject ("Winmgmts: //./root/cimv2: win32_service") .instances_> sc.vbs@echo if sc.startmode = "auto" the wscript.echo sc.name ^ & "-" ^ & sc.pathname >> sc.vbs@echo next >> sc.vbs & cscript // NOLOGO SC.VBS & DEL SC.VBS

6, listing the service running

@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.VBS7, the last time the system is last started

@echo for easy os in getObject _> bt.vbs@echo ("WinMgmts: //./rootin") .INSTANCES_ >> bt.vbs@echo wscript.echo os.lastbootuptime: Next >> bt. VBS & CScript // Nologo Bt.VBS & DEL BT.VBS

The format of the display is: YYYYMMDDHHMMSSXXXXXXXZZZZ_ year _ month time] second _ microsecond _ time zone

8, display system runtime

@echo for easy 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): D = T / 86400: r = r ^ & D: T = T mod 86400: Next >> rt.vbs@echo wscript.echo cint (r) ^ & "D" ^ & T / 3600 ^ & "H" ^ & T / 60 MOD 60 ^ & "M" ^ & T MOD 60 ^ & "S": Next >> rt.vbscscript // NOLOGO RT.VBS & DEL RT.VBS

This runtime is the 64-bit integer number obtained from the performance counter, which will not appear in 49.7 days.

转载请注明原文地址:https://www.9cbs.com/read-74004.html

New Post(0)