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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: 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