Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
How to detect a running application in Windows?

Posted by neilvp (neilvp), 24 April 2006
Guru Graham

In one of my TCL scripts I output the result to Notepad using exec. The problem is my colleagues find this script so useful and use it so often at times that they find themselves with multiple instances of notepad open.
Is there a way I can detect that notepad (or any other Windows app) is already running and then either shut that one down first (if so how?) or 'over write' it rather than open another instance?  

Or should I just tell my colleagues not to be so lazy?

Many thanks

Neil





Posted by admin (Graham Ellis), 24 April 2006
That's a good one, Neil.   I'm training a load of supergeeks today and I threw the question to them over coffee ... they agreed it's a good one too.  Which doesn't help you!

I'll be home / back to my Tcl library briefly on Wednesday evening - I'll have a look then if that's not too late?   It's probably a question of getting into the Windows registry and reading from there so I'm likely to be on thin ice.

Posted by neilvp (neilvp), 24 April 2006
Stumped even the SuperGeeks, wow !

Wednesday or Thursday is fine by me. The problem does not stop the script from working and is a 'nice to have' rather than an absolutely necessary bit of code.  (Though it would be useful to know.)

Many thanks Graham, your help and support are very much appreciated.



Posted by admin (Graham Ellis), 25 April 2006
I had an unexpected chance to do some researching on this last night - no single all-in-one-place answer but I came across:

1. The registry command in Tcl allowing you to talk to the windows registry:
http://www.tcl.tk/man/tcl8.4/TclCmd/registry.htm

2. Structure for Notepad (setups at least) in the registry
http://www.winguides.com/registry/display.php/1216/

3. A sample program (in Perl, sorry) that checks what programs are running on what computer ... see especially the code towards the end
http://w3.misterhouse.net:8090/bin/browse.pl?/user_code/monitor_programs.pl

An interesting challenge to put all of these together!

Posted by neilvp (neilvp), 25 April 2006
And I thought it such an innocent little question!

Thanks for these pointers, this should give me enough to go on.

I have also had a response from the ActiveState forum where the suggestion is to look at the use of TWAPI. See http://wiki.tcl.tk/9886.

There is a further suggestion that the process ID returned by exec be written to file for later referal - so I know which processes to kill if the script is re-run. Will this work?  Is the process ID a Windows value and therefore persistent or unique to the TCL app?





This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho