Jump to content

How to processclose using wmi?


euverve
 Share

Recommended Posts

  • Moderators

I would like to ask how could i close a certain process using WMI?

Please help, thanks

Curious, why must it be with WMI?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

@Thatskie

Maybe this can get you going.

Dim $objWMIService, $objProcess, $colProcess
Dim $strComputer, $strProcessKill, $strInput 
$strProcessKill = "'calc.exe'" 

; Input Box to get name of machine to run the process
Do 
    $strComputer = (InputBox(" ComputerName to Run Script","Computer Name"))
    If $strComputer <> "" Then
    $strInput = 1
    EndIf
Until $strInput = 1


 $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") 

 $colProcess = $objWMIService.ExecQuery ("Select * from Win32_Process Where Name = " & $strProcessKill )
 
For $objProcess in $colProcess
    $objProcess.Terminate()
Next 
ConsoleWrite ("Just killed process " & $strProcessKill & " on " & $strComputer & @CRLF)

regards

ptrex

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...