Archive: FCT and closing application


FCT and closing application
I have tested this cript, it a modified script of the one coming with FCT;

!define APP_NAME fct
!define WND_CLASS "Outlook Express Browser Class"
!define CLASS_PART "Browser Class"
!define WND_TITLE "Dice100lient"
!define TITLE_PART "Express"
!define termMsg "Installer cannot stop running ${WND_TITLE}.$\nClick YES to terminate application."

!include WinMessages.nsh

Name "${APP_NAME}"
OutFile "${APP_NAME}.exe"

Section "Dummy Section" SecDummy


; sync termination
# fct::fct /WC '#32770' /UDATA 0x4d475200
fct::fct /WT '${WND_TITLE}' /TIMEOUT 2000 /QUESTION '${termMsg}'

Pop $0
MessageBox MB_OK "Still Alive Count = $0"

SectionEnd

My problem here is that it seems like it never finds my application.
Ive written a visual basic program with autoupdate. The update is patch is nsis made. The problem with it is that the installer script is finished running before the APP has managed to shutdown.

So is there a easy way to make FCT or something identical check if an app is still running and if so wait for it to stop?

What this WND_Class and CLASS_Part is I have no idea, all I know is where the app is running from and that is named Dice100Client.exe

The Count returns 0 as its running.


You sure "Dice100lient" is correct?
It has to be identical to the actual window title (or use /WTP to specify just part of the title).

The class name is a unique name for windows, which should be used over window titles in case the title differs over different languages.

Stu


You sure "Dice100lient" is correct?
It has to be identical to the actual window title (or use /WTP to specify just part of the title).

The class name is a unique name for windows, which should be used over window titles in case the title differs over different languages.

Stu


Thanks Stu, you spotted what I couldn't see. A C was all the difference infront of lient. Now it workes.
But is it possible with FCT to detect if a program is running and then just wait until it terminates?
Because the VB program exits when it has downloaded the update and executed it.

It should not throw up any messagebox, just wait until it exits, then continue.


The wiki has a function FindProcess you can use in a loop:

${Do}
${FindProcess} "Dice100Update.exe" $0
Sleep 200
${Loop} ${While} $0 <> 0
Don

Many Thanks for the tip Demiller9. Its just what I'm looking for. Added it to my script. But now I get a new problem that puzzles me.

Invalid command: ${WordFind}
!include: error in script: "C:\Program Files (x86)\NSIS\Include\FindProcess.nsh" on line 58
Error in script "E:\Project Dice100\InstallMaker\Dice100Updaterscript.nsi" on line 9 -- aborting creation process

Why is it stopping at ${WordFind}. The script is copied straight from the Wiki and these are in the script;

!include LogicLib.nsh
!include WordFunc.nsh

Here is the offending line;

${WordFind} '$2' ',' 'E/$1' $0


You're missing !insertmacro WordFind after !include.

Stu


Thanks. Added it and gort this error message;

Error: can't change compressor after data already got compressed or header already changed!
Error in script "E:\Project Dice100\InstallMaker\Dice100Updaterscript.nsi" on line 29 -- aborting creation process

line 01 to 29 in my install script

############################################################################################
# NSIS Installation Script created by NSIS Quick Setup Script Generator v1.09.18
# Entirely Edited with NullSoft Scriptable Installation System
# by Vlasis K. Barkas aka Red Wine red_wine@freemail.gr Sep 2006
############################################################################################
!include Library.nsh
!include "WordFunc.nsh"
!insertmacro WordFind
!include LogicLib.nsh
!include "FindProcess.nsh"
!define APP_NAME "Dice100"
!define COMP_NAME "TwistedMind"
!define VERSION "1.1.0.17"
!define COPYRIGHT "GenRabbit"
!define DESCRIPTION "Application"
!define INSTALLER_NAME "E:\Project Dice100\InstallMaker\Dice100Update_101017.exe"
!define MAIN_APP_EXE "Dice100Client.exe"
!define INSTALL_TYPE "SetShellVarContext current"
######################################################################

VIProductVersion "${VERSION}"
VIAddVersionKey "ProductName" "${APP_NAME}"
VIAddVersionKey "CompanyName" "${COMP_NAME}"
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
VIAddVersionKey "FileDescription" "${DESCRIPTION}"
VIAddVersionKey "FileVersion" "${VERSION}"

######################################################################
SetCompressor ZLIB

Strange, I can't find "SetCompressor" anywhere else..


Error: can't change compressor after data already got compressed or header already changed!
That is because the 'include "FindProcess.nsh"' was ahead of the 'SetCompressor' statement. There are two functions in the FindProcess file, and they might have been buffered for the default compressor already. Move the include down after you do the SetCompressor ZLIB (or move the SetCompressor up) and it should clear the error.

I'll update the wiki page to show the !insertMacro WordFind, too. I created that page late last night from a larger script that used that function and forgot to include that 'insertmacro'.

Don

Thanks again, moved the Setcompressor in the start, and voila, no more a problem. Then added;

${Do}
${FindProcess} "Dice100Update.exe" $0
Sleep 200
${Loop} ${While} $0 <> 0

This would not compile.

Changed it to

${Do}
${FindProcess} "$PROGRAMPATH\Dice100Client.exe" $0
Sleep 200
${LoopUntil} $0 <> 0

and it runs in infinite loop. I can't get out of without using alt+ctrl+del.

Also tried with just Dice100Client.exe as process. But runs in infinite loops either if Dice100Client.exe runs or not.

Any idea why?


But runs in infinite loops either if Dice100Client.exe runs or not.
Any idea why?
Yes. I should have tested it better. My application needed to wait for two processes, and the function I posted expected to find a comma in the list. I fixed it (in the wiki too) by changing the 'StrCpy $2 $0' at line 30 to add a comma: StrCpy $2 "$0,"

Also, the loop should read
  ${Do}
${FindProcess} "Dice100Client.exe" $0
Sleep 200
${LoopWhile} $0 <> 0
Don't include the path, and the loop repeats while $0 is true, so it should be LoopWhile.

Don

Thank you all. Now it works great.
Excellent script Demillier9, any chance in future it will include the chance to check if the appname runs from a certain location too?

Anyway now the script seems to run like it supposed too. Thanks again all.