trwagner1 Posted April 23, 2008 Share Posted April 23, 2008 I'm working on an automated enterprise program installation that includes multiple application installs. During one of the individual installations, the application launches a process that is sent to the system tray. Let's call it "something.exe" It cannot be accessed through a window, it's just a tray program that is running. And, there's no hot-key to activate the application. But, in order for the installation to continue, I have to terminate that exe. Here are two code snippets of what I've been trying: $Process = "something.exe" while 1 If ProcessExists($Process) Then ProcessClose($Process, 2) Sleep(5000) EndIf WEnd MsgBox(0,"",$Process & " Terminated",0) Exit And $Process = "something.exe" while 1 If ProcessExists($Process) Then Do ProcessClose($Process, 2) Until Not ProcessExists($Process) EndIf WEnd MsgBox(0,"",$Process & " Terminated",0) Exit In both cases, the compiled AutoIt exe runs then pauses. It never closes the process and the application never ends itself. I've also just tried simply: $Process = "something.exe" ProcessClose($process) and $Process = "something.exe" ProcessWaitClose($process) With similar results. Additionally, I'm using the local admin to perform all the steps within the script. I use the RunAsWait() as one of the first functions in the script. From what I'm reading, ProcessClose($Process, 2) should forcefully close the process. But, it's not. Is there an altnerate method? Thanks Ted Link to comment Share on other sites More sharing options...
spudw2k Posted April 23, 2008 Share Posted April 23, 2008 If you could give some insight to the application, we may be able to help automate closing it; but if it's a protected process like a virus scanner, this is not the right forum. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
trwagner1 Posted April 23, 2008 Author Share Posted April 23, 2008 If you could give some insight to the application, we may be able to help automate closing it; but if it's a protected process like a virus scanner, this is not the right forum.The application is a proprietary application. QA Director from Compuware.The application itself is a little exe that's called a "test execution server". I can right click on it and select exit as any logged in user (admin or otherwise).Is there a way to use AutoIt to block a process from executing?Ted Link to comment Share on other sites More sharing options...
Richard Robertson Posted April 23, 2008 Share Posted April 23, 2008 There are tray management functions that let you interact with the tray icons and menus. I believe they are UDFs and you can find them by trying different search terms. Try searching for something like "+system +tray +menu". Link to comment Share on other sites More sharing options...
Siao Posted April 23, 2008 Share Posted April 23, 2008 (edited) From what I'm reading, ProcessClose($Process, 2) should forcefully close the process. But, it's not. Is there an altnerate method? I wonder, did you read this part: ProcessClose Parameters process The title or PID of the process to terminate. flag [optional] if different from zero will force closing of handles to child stream if any defined in the Run() execution. process must be defined as a PID. So if you have $Process = "something.exe" then it should be ProcessClose(ProcessExists($Process), 1) Edited April 23, 2008 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
trwagner1 Posted April 23, 2008 Author Share Posted April 23, 2008 Siao,Yes, I tried that as well. Sorry did not include that in the original post.But, that did not work as well.TedI wonder, did you read this part:So if you have$Process = "something.exe"then it should beProcessClose(ProcessExists($Process), 1) Link to comment Share on other sites More sharing options...
trwagner1 Posted April 23, 2008 Author Share Posted April 23, 2008 Thanks Richard, I will do some digging and experimenting with that.If I figure it out, I will post my solution.TedThere are tray management functions that let you interact with the tray icons and menus. I believe they are UDFs and you can find them by trying different search terms. Try searching for something like "+system +tray +menu". Link to comment Share on other sites More sharing options...
trwagner1 Posted April 24, 2008 Author Share Posted April 24, 2008 (edited) Wow, this worked great.Because the process didn't close 100% of the time using ProcessClose() I followed Richard's suggestion and found the discussion related to SysTray_UDF.So, here's how I closed that exe (generic code follows. replace something.exe with your tray app executable name)#include <SysTray_UDF.au3> clickfunc() Func clickfunc() $index = _SysTrayIconIndex("something.exe", 0) $pos = _SysTrayIconPos($index) MouseClick("Right", $pos[0], $pos[1], 2) Send("x") EndFunc ;==>clickfunc ExitMany thanks to the SysTray_UDF reference. I got the solution from the large taupe thread.SysTray_UDF ThreadNote: If you use the code above, you can't use the systray_udf file found in the general install! You have to use the one found here: NEW SysTray_UDF.au3 Edited April 24, 2008 by trwagner1 Link to comment Share on other sites More sharing options...
Richard Robertson Posted April 24, 2008 Share Posted April 24, 2008 Glad to help. As soon as I read that it could be closed by user interactive means, it just made sense to close it that way. 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