Jump to content

Remote processclose


Recommended Posts

I am trying to avoid using pskill if possible. I need to kill a process on a remote machine. Can I do that with AutoIt code only?

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

Try this Converted VB WMI example.

Local $objWMIService, $objProcess, $colProcess, $strComputer, $strProcessKill 
$strComputer = ".";replace with remote computer
$strProcessKill = "'calc.exe'" 

$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

Original code http://www.computerperformance.co.uk/vbscr...rocess_stop.htm

Edited by Larry
Link to comment
Share on other sites

Try this Converted VB WMI example.

Local $objWMIService, $objProcess, $colProcess, $strComputer, $strProcessKill 
$strComputer = ".";replace with remote computer
$strProcessKill = "'calc.exe'" 

$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

Original code http://www.computerperformance.co.uk/vbscr...rocess_stop.htm

Thanks. Works like a charm. Going from shell scripts straight to AutoIt, I tend to forget about Vb.

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

I like WMI :rolleyes:

#include <Array.au3>
Local $objWMIService, $objProcess, $colProcess, $strComputer, $strProcessKill
Local $procs
$strComputer = ".";replace with remote computer

$objLoc = ObjCreate("wbemscripting.swbemlocator")
$objLoc.Security_.privileges.addasstring("sedebugprivilege", true)

$objWMIService = Objget("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& $strComputer & "\root\cimv2")
$colProcess = $objWMIService.ExecQuery _
("Select * from Win32_Process" )
For $objProcess in $colProcess
    ConsoleWrite($objProcess.CommandLine&@LF)
Next

Get process list and COMMAND LINE of all running processes on remote compy

I only know of 1 program that will get you the command line arguments, ProcExp by sysinternals.

Link to comment
Share on other sites

I was able to get this to work in my script with a small modification but I am now trying somethign a little different. If I use the above code and hard code $strProcessKill, it works. I want to now use an inputbox to allow the user to supply the process to kill. I thouht I was really on the road to success but the below code doesnt work. I dont get an error but the process never dies. What am I missing here?

$process = InputBox("Prosess Name", "Enter the process[ÝHÚÚÈÝÜ    ][ÝÊBÌÍÜÝØÙÜÒÚ[HÕRPÝXY
    ÌÍÜØÙÜÊB33c¶ö&¥tÔ6W'f6RÒö&¤vWBgV÷C·væÖv×G3¢gV÷C²ð fײgV÷C·¶×W'6öÑ¥½¹1Ù°õ¥µÁÉͽ¹ÑôÌÌìÀäÈìÀäÈìÅÕ½Ðì|($$µÀìÀÌØíI%¹ÁÕÐmp; "\root\cimv2")
                
$colProcess = $objWMIÙXÙK^XÔ]YHÂBJ  ][ÝÔÙ[XÝ
ÛHÚ[ÌÔØÙÜÈÚH[YHH   ][Ýfײb33c·7G%&ö6W74¶Æ¤f÷"b33c¶ö&¥&ö6W72âb33c¶6öÅ&ö6W70¢ÀÌØí½©AɽÍ̹Qɵ¥¹Ñ ¤)9áÐ(

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

$strComputer = InputBox("Computer name", "Enter the computer's name")
$strProcessKill = InputBox("Prosess Name", "Enter the process you wish to stop")
$strProcessKill="'"&$strProcessKill&"'" <----- NEEDED THIS BIT

$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

Edited by Zacharot
Link to comment
Share on other sites

Thanks for the help. I think I see why. I'll be a process killing fool come Monday. :rolleyes:

Edited by ksmith247

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

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...