Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 7th October 2005, 08:36   #1
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Wait for a process to end I didn't start?

Simple and short. How do I get the installer
to wait on a process to end I didn't start?

I need something like "ExecWait" for a process, yet the
process isn't executed by my installer. I need to pause
the installer without a messagebox until the process I
choose isn't running any longer. I keep coming across
a dead link within a recurring solution in threads posted
by Kichik. Here is a link to one of those threads below.

Thread:
http://forums.winamp.com/showthread....+installshield

Dead link:
http://unattended.sourceforge.net/installers.html

-MichaelFlya-

Last edited by MichaelFlya; 7th October 2005 at 09:01.
MichaelFlya is offline   Reply With Quote
Old 7th October 2005, 09:26   #2
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,220
For apps with window:
code:

!macro TerminateApp

StrLen $5 "${PROG_NAME}"
IntOp $5 $5 + 1 ; terminating 0 for caption to compare

restart:
StrCpy $0 "0"

loop:
; FindWindow $0 '' '' 0 $0
FindWindow $0 'WindowsForms10.Window.8.app1' '' 0 $0
IntCmp $0 0 done
System::Call 'user32.dll::GetWindowText(i r0, t .r4, i r5) i .r2'
StrCmp $4 "${PROG_NAME}" 0 loop
System::Call 'user32.dll::GetWindowThreadProcessId(i r0, *i .r1)'
System::Call 'kernel32.dll::OpenProcess(i 0x00100000, i 0, i r1) i .r2'
SendMessage $0 0x0010 0 0 /TIMEOUT=2000
System::Call 'kernel32.dll::WaitForSingleObject(i r2, i 3000) i .r3'
IntCmp $3 0 done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "Installer cannot terminate \
running ${APP_NAME}.$\nClose Application and re-run Installer." IDOK restart
Quit
done:

!macroend

Takhir is offline   Reply With Quote
Old 7th October 2005, 09:58   #3
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Ok I start up the process "notepad.exe" after
which I start up my installer and hit install.

Now if the code works correctly the installation
should pause with the loading bar not moving till
I close notepad. How do I insert this in the script
correctly and properly?

-MichaelFlya-
MichaelFlya is offline   Reply With Quote
Old 7th October 2005, 10:05   #4
KenA
Junior Member
 
Join Date: Jul 2004
Posts: 36
Re: Wait for a process to end I didn't start?

Quote:
Originally posted by MichaelFlya
Simple and short. How do I get the installer
to wait on a process to end I didn't start?

I need something like "ExecWait" for a process, yet the
process isn't executed by my installer. I need to pause
the installer without a messagebox until the process I
choose isn't running any longer. I keep coming across
a dead link within a recurring solution in threads posted
by Kichik. Here is a link to one of those threads below.

Thread:
http://forums.winamp.com/showthread....+installshield

Dead link:
http://unattended.sourceforge.net/installers.html

-MichaelFlya-
Hi Michael,

for processes that don't include a window, you should use the FindProcDLL plug-ins - I never remember if all those plug-in I use are in the standard NSIS install, sorry - in a loop and exit the loop if the process is not found.

I'd also advise you to use a sleep instruction in your loop, or else you might peg the processor if your loop is tight.

KenA
KenA is offline   Reply With Quote
Old 7th October 2005, 10:24   #5
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,220
Notepad window class name is 'Notepad' (for FindWindow).
For this specific window class you can skip 4 lines of window caption check out (2 lines at the beginning and GetWindowText+StrCmp in the loop). And " - Notepad" text is lang dependant and appears at the end of caption (like IE does). Please note 2000 and 3000 msec timeouts in the code. Usage:

!insertmacro TerminateApp
Takhir is offline   Reply With Quote
Old 7th October 2005, 10:30   #6
MichaelFlya
Member
 
MichaelFlya's Avatar
 
Join Date: May 2005
Location: U.S.A.
Posts: 91
Well, KenA has a good solution it seems.
Using the plugin found at this link:
http://nsis.sourceforge.net/wiki/Find_Process_By_Name


Plus using the code below. Which did the trick.


code:

Section "Test"
Loop:
FindProcDLL::FindProc "notepad.exe"
StrCmp $R0 0 0 +2
;MessageBox MB_OK "The number is $R0 meaning it is not found."
Goto Done
StrCmp $R0 1 0 +2
;MessageBox MB_OK "The number is $R0 meaning it is found."
Goto Loop
Done:
SectionEnd


Thanks !!


-MichaelFlya-
MichaelFlya is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump