Jump to content

Looking for ideas/help/pointers with an application management issue.....


Recommended Posts

Hi All,

I've an issue with vendor supplied application which for one reason & another doesn't like to coexist within a session with a host of other specific applications.

The problematic application ceased development quite a few years ago & now has minimal support from the vendor, so I have drawn a blank when discussing the issue with them.

To give a brief overview of how the application performs........ the exe is called by another process & purely acts a an initiator between the user & the other process, once this initiation has taken place the exe is theoretically useless however stays in situ as a minimized presence serving no purpose - Whilst sitting serving no purpose the exe causes other applications to become unstable.

My thoughts have now turned to having an automated process to exit the application after a period of time, I initially knocked together the below simple process of opening the exe in question

Local $sUsername = "******"
Local $sPassword = "******"
Local $sDomain = "******"

RunAs ($sUsername, $sDomain, $sPassword, 0, 'C:\Original.exe')


Sleep(15000)

ProcessClose("Original.exe")

However (unfortunately) this doesn't work as the original exe has to be called from the process therefore I need something to possibly sit in the background & monitor (real time) to see if + when the executable is present then exit the process..... which is the point I'm struggling at.

Can anyone suggest a route to take? any ideas or pointers?

Any help would be greatly appreciated.

Many Thanks

Bob

Link to comment
Share on other sites

Global $sProcess = "Original.exe"
Local $sUsername = "******"
Local $sPassword = "******"
Local $sDomain = "******"

RunAs ($sUsername, $sDomain, $sPassword, 0, 'C:\' & $sProcess)

Sleep(15000)

AdlibRegister("_LoopClose", 100) ; every 100ms run _LoopClose()

While 1
Sleep(10)
WEnd

Func _LoopClose()
Local $aList
$aList = ProcessList($sProcess)
If @error Or not $aList[0][0]Then Return
For $i = 1 To $aList[0][0]
If ProcessExists($aList[$i][1]) then
ProcessClose($aList[$i][1])
ConsoleWrite(@MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & " Closed: " & $aList[$i][0] & @CRLF)
Exit 0
EndIf
EndFunc

EDIT: Added 'Or not $aList[0][0]' in _LoopClose()

Hi Mechaflash,

Thank you for the reply (& speed of it) & code.

I don't think I've maybe explained myself fully though (apologies), basically the executable (oringinal.exe) would be run on occasion through the day & I need something to sit there & monitor for when the 'original.exe' appeared then after 15 second sleep period processclose.

So there wouldn't be a requirement for the 'RunAs..' if that makes sense.

So theoretically a 'monitor.exe' would be sat in the wings looping for 'original.exe' to appear as a running process then grace 15 seconds sleep before closing the process.

Thanks

Bob

Link to comment
Share on other sites

If you need your exe to run occasionally, have you thought about using Windows Task Scheduler to run it at specified times during the day? That way, your exe wouldn't be constantly running and interfere with the program you want to run.

Hi abberration,

Thanks for the response.

That wouldn't work, I've roughly around 200 users all requiring random access to the executable (which requires the monitoring) - All the executable does is pass information inc security details in a formatted way to a SQL instance, once the initial handshake has been completed the executable can be ended however there are no switches/parameters etc in which I can pass to end it so it just sits there in a minimized state & basically causes issues with other well know apps MSO 2010, Acrobat X, IE9, etc

What I basically need is something to sit 'listening' for the executable to open, when it's opened & picked up as being a running process given around 15 seconds sleep then a process close passed to the executable - After this i'll need to add further code to 'sort' some other loose ends.

In essence all I'm after is something to listen, pick up that the exe has open wait 15 seconds before closing it if that makes sense....?

Thanks again to all for the replies.

Bob

Link to comment
Share on other sites

While 1
    If ProcessExists("SomeProcess") Then
        Sleep(15000)
        If ProcessExists("SomeProcess") Then ProcessClose("SomeProcess")
    Endif
    Sleep(1000)
Wend

Put this in the startup folder, or in the Registry for Run, or in Scheduled Tasks and have it run at log on. As long as the user is logged in, this will run in the background. If it detects the process "SomeProcess", it will sleep itself for 15 seconds, check to see if it's still running and close it. If it doesn't detect the process, or it has finished closing the process, it will then sleep for 1 second before checking again.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

updated my original post up top

Just use Brew's lol

@BrewMan. Will process names (original.exe) work in place of the process ID the function specifies it needs?

Edited by Mechaflash
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

ProcessExists and ProcessClose will take either a PID or a process name ("original.exe") as its argument.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

While 1
If ProcessExists("SomeProcess") Then
Sleep(15000)
If ProcessExists("SomeProcess") Then ProcessClose("SomeProcess")
Endif
Sleep(1000)
Wend

Put this in the startup folder, or in the Registry for Run, or in Scheduled Tasks and have it run at log on. As long as the user is logged in, this will run in the background. If it detects the process "SomeProcess", it will sleep itself for 15 seconds, check to see if it's still running and close it. If it doesn't detect the process, or it has finished closing the process, it will then sleep for 1 second before checking again.

updated my original post up top

Just use Brew's lol

@BrewMan. Will process names (original.exe) work in place of the process ID the function specifies it needs?

Thanks for the replies & apologies mine is a few days behind, not been in the office.

BrewMan, perfect..... I thought there would be an obvious answer (lack of knowledge on my part), I'd have to run this as a single entity as opposed to how I had a vision of adding it to some other script parts (more so calling sprocs, sql being the day job).

It's perfect though for the problem at hand, so thank you again.

Thanks for the update pre-removal Mechaflash.

I've created a service to call & this will be housed on a farm of citrix servers, with a test pool it worked perfectly - I'll shunt the other code to a separate prog.

Thanks again to all.

Bob

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