Sign in to follow this  
Followers 0
ksmith247

Remote processclose

8 posts in this topic

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]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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]

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

$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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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]

Share this post


Link to post
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
Sign in to follow this  
Followers 0