Take the 2-minute tour ×

I am using InstallJammer for setup creation of my application. I want to check if the application is running before proceeding with uninstall procedure.

set program <%Company%><%AppName%>.exe
set pids [twapi::get_process_ids -name $program]
foreach pid $pids {
    catch {twapi::end_process $pid -force}

Above given is the TCL script I tried. But the script does not return any values. How to solve this.?

share|improve this question
This script tries to kill any running application which happens to have a matching name; strictly speaking, it does not check anything, so there's nothing to return. I would say this should be clear from the invocation of something called "end_process"... –  kostix Jan 15 '13 at 14:06
On the other hand, it's not clear what you mean by "returning a value" -- how is your caller code supposed to get access to that value? A reference to the relevant bit of that "InstallJammer" documentation could help understand the requirements. –  kostix Jan 15 '13 at 14:08
@kostix Is there any way to check if application is running? On searching this question, I got the above script as solution. installjammer.com/forums/viewtopic.php?f=5&t=2261 –  Gapchoos Jan 15 '13 at 14:39
twapi::get_process_ids -name $program returns a list of PIDs of the running processes which name matches $program. If the list is non-empty, you have your application running. That is, expr {[llength [twapi::get_process_ids -name $program]] > 0} returns true only if you have at least one matching process currently running. –  kostix Jan 15 '13 at 14:45
@Gapchoos, I can't as I do not even know what that "installJammer" thing really is. Well, I have a vague idea that this is supposedly a tool to prepare installable packages but that's all. Since I don't know how it is supposed to interact with the Tcl scripts it executes, I can't provide a full script. The snipped I posted in my previous comment should return true or false depending on whether the indicated program is found running or not. You could try to work from there. –  kostix Jan 16 '13 at 10:15
show 2 more comments

1 Answer

I assume that you are using the execute script condition, while it might be easier to just use the script condition

If you use the script condition, just use the expr given by kostix:

[llength [twapi::get_process_ids -name <%Company%><%AppName%>.exe]] > 0

If you really have to use the execute script condition, then just wrap everyting in expr { and } and you get the same result as the script condition (Or: a script condition is just a execute script condition with expr { at the beginning and } at the end).

share|improve this answer
add comment

Your Answer


