80 likes | 296 Views
Windows Management Instrumentation (WMI). Abbas Al Ali 441 Ali Al Mohana 448 Murtadah Al Nasser 459 Ammar Al Abdullwahab 463 Mohammed Al Dokhi 468. Windows Management Instrumentation (WMI).
E N D
Windows Management Instrumentation (WMI) Abbas Al Ali 441 Ali Al Mohana 448 Murtadah Al Nasser 459 Ammar Al Abdullwahab 463 Mohammed Al Dokhi 468
Windows Management Instrumentation (WMI) • WMI (Windows Management Instrumentation) commands? “Here are the people who I had in mind as I wrote this section. Network managers who want to collect specific data from one (or more) server. IT professionals who what to know precisely what's happening in their Microsoft operating system. Those techies who love remote control without hassle”. • http://www.computerperformance.co.uk/vbscript/wmi.htm (accessed on 14th of April)
Example 1: process termination • WMI Script to Terminate a Process on the Local Machine • ' ProcessKillLocal.vbs' Sample VBScript to kill a program' Author Guy Thomas http://computerperformance.co.uk/' Version 2.7 - December 2010' ------------------------ -------------------------------' Option ExplicitDim objWMIService, objProcess, colProcessDim strComputer, strProcessKillstrComputer = "."strProcessKill = "'calc.exe'" Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colProcess = objWMIService.ExecQuery _("Select * from Win32_Process Where Name = " & strProcessKill )For Each objProcess in colProcessobjProcess.Terminate()Next WSCript.Echo "Just killed process " & strProcessKill _& " on " & strComputerWScript.Quit' End of WMI Example of a Kill Process
Example 2: process termination • WMI Script to Terminate a Process on a Distant Machine • ' ProcessKillRemote.vbs' Sample VBScript kill process' Author Guy Thomas http://computerperformance.co.uk/' Version 2.9 - December 2010' ------------------------ -------------------------------' Option ExplicitDim objWMIService, objProcess, colProcessDim strComputer, strProcessKill, strInputstrProcessKill = "'calc.exe'" ' Input Box to get name of machine to run the processDo strComputer = (InputBox(" ComputerName to Run Script",_"Computer Name"))If strComputer <> "" ThenstrInput = TrueEnd ifLoop until strInput = TrueSet objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")Set colProcess = objWMIService.ExecQuery _("Select * from Win32_Process Where Name = " & strProcessKill )For Each objProcess in colProcessobjProcess.Terminate()NextWSCript.Echo "Just killed process " & strProcessKill _& " on " & strComputerWScript.Quit' End of WMI Example of a Kill Process
Summary • WMI • Example 1 • Example 2