ksmith247 Posted June 22, 2007 Share Posted June 22, 2007 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 More sharing options...
ChrisL Posted June 22, 2007 Share Posted June 22, 2007 (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() NextOriginal code http://www.computerperformance.co.uk/vbscr...rocess_stop.htm Edited June 22, 2007 by Larry [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ksmith247 Posted June 22, 2007 Author Share Posted June 22, 2007 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 More sharing options...
ChrisL Posted June 22, 2007 Share Posted June 22, 2007 Welcome. Nice editing Larry!!! [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 I like WMI #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 More sharing options...
ksmith247 Posted June 22, 2007 Author Share Posted June 22, 2007 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 More sharing options...
Zacharot Posted June 22, 2007 Share Posted June 22, 2007 (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 June 22, 2007 by Zacharot Link to comment Share on other sites More sharing options...
ksmith247 Posted June 22, 2007 Author Share Posted June 22, 2007 (edited) Thanks for the help. I think I see why. I'll be a process killing fool come Monday. Edited June 22, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now