- NSIS Discussion
- Close Running Application
Archive: Close Running Application
Yathosho
22nd January 2002 23:29 UTC
Close Running Application
i remember the FindWindow command in NSIS 1.4x could detect if a software was running during the installation-process and close it.
now that the commands changed, i'm in need of help.
i want my setup to
1) detect if winamp is running and force the user to close it
or
2) close winamp without asking
if you can help me, please paste the syntax. the makensis.html wasnt a big help for me!
thx in advance,
kb
rainwater
22nd January 2002 23:55 UTC
This is from functions.htm in the nsis distro:
CloseWinamp
Push$0
loop:
FindWindow $0 "Winamp v1.x"
IntCmp $0 0 done
SendMessage$0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd
>
Yathosho
23rd January 2002 00:02 UTC
i remember i tried this before. nothing happening. reading the makensis.html it should be possible with FindWindow/SendMessage, but i have no clue how that works. this function does nothing, but thanks anyhow for the quick reply!
rainwater
23rd January 2002 00:40 UTC
I just ran it and it closed winamp just like it should. Are you calling the function?
Yathosho
23rd January 2002 01:28 UTC
i did copy+paste =)
what version of nsis did you use? mine is 1.94
rainwater
23rd January 2002 01:40 UTC
I'm using 1.94
Name "CloseWinamp"
>Outfile "closewinamp.exe"
>Section -
Call CloseWinamp
SectionEnd
>Function CloseWinamp
Push$0
loop:
FindWindow $0 "Winamp v1.x"
IntCmp $0 0 done
SendMessage$0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd
>
F. Heidenreich
23rd January 2002 05:54 UTC
This will not work for the current BETA of Winamp. If you want to close a BETA version simply replace
FindWindow*$0*"Winamp*v1.x"
with
FindWindow $0 "STUDIO"
~ Florian
rainwater
23rd January 2002 15:31 UTC
Doh. It never crossed my mind they might be refering wo Winamp 3. :cool:
Yathosho
23rd January 2002 21:51 UTC
thank you very much! works now, and i added both functions to support both versions =)
cchian
24th January 2002 05:34 UTC
Excuse my ignorance on this topic, but how do you find out the name of the Window you want to close if you did not write the application you are trying to close?
-Carlos
F. Heidenreich
24th January 2002 08:38 UTC
Carlos,
there is a tool called Spy++ that ships with Visual Studio. With this tool you could identify the window class or window handle of every open window.
There are similar tools called Window Finder (which ships with source code) and WinSpy.
Kichik uploaded the Spy program from the platform SDK at this thread.
~ Florian
cchian
24th January 2002 13:57 UTC
Thank you for all those useful links Florian, they worked great!!!
-Carlos
benp
25th January 2002 14:01 UTC
kill task
is there an other way to close apps like the above one
i mean a command like kill (killtask ...)"exename"
is more simplier than write everytime a function like the findwindow...
is there a way to implement this command in the next releases of nsis
sorry for my bad english:confused:
Pomflain
25th January 2002 14:36 UTC
Just make a function to do that an always pass in "exename" in one of thhe registers. Name the function "killtask" if you want, then just Call killtask
benp
25th January 2002 15:00 UTC
example
can you give me an example please???:hang:
rainwater
25th January 2002 16:44 UTC
CloseApplication
Pop$1
Push$0
loop:
FindWindow $0 $1
IntCmp$0 0 done
SendMessage$0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd
>Function .onInit
Push "Winamp v1.x"
Call CloseApplication
FunctionEnd
>
Push the class name of the application before calling it, then the closeapplication will close it.
benp
25th January 2002 17:04 UTC
ah
ah yes ok thank you :) :) :)
benp
26th January 2002 14:11 UTC
no
that way wont work because the task i want to close runs in the background
i have found the window name but it close only the (invisible) window and not the task
the task is still shown in taskmon
is there an other way to close this because i can not write over the file
please help :confused: :confused:
ksyksy
28th January 2002 06:11 UTC
please Tell me!! help me!!
I can not English Very well.
I want to closeing MYSQL daemon.
please Tell me. help.
Function CloseWinamp
Push $0
loop:
FindWindow $0 "Winamp v1.x" <== How Can i set...
IntCmp $0 0 done
SendMessage $0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
felfert
28th January 2002 07:09 UTC
In case of MySQL, you can NOT simply kill the daemon. If you do that, you will probably loose database consitency. Instead, simply run the mysqladmin commandline-tool:
C:\mysql\bin\mysqladmin shutdown
This terminates the server gracefully.
From within your script, this would be:
stopMySQL
ExecWait "C:\\mysql\\bin\\mysqladmin shutdown"
>FunctionEnd
>
Note:
Depending on your setup, this probably needs to specify a database admin-user and his password on the commandline.
See mysql docs...
A question:
Why do you want to shutdown the DB-server?
Nearly anything can be done
without shutting down MySQL.
-Fritz
ksyksy
28th January 2002 07:21 UTC
Just, I want to Know... Mysql Daemon State.
How do i know... MySQL Daemon State. (RUNning? OR Not RUNning)
If (MySQL daemon == running) Sending SQL query To MySQL server.
else message "Please Running MySQL Daemon"
<= please teach me. help me.
How can i know MySQL Daemon State.
linuxamp
13th March 2002 08:59 UTC
Re: ah
Originally posted by benp
that way wont work because the task i want to close runs in the background
i have found the window name but it close only the (invisible) window and not the task
the task is still shown in taskmon
is there an other way to close this because i can not write over the file
yes that is true.
it is March, did you find a way to cloes the running task?:)
thank you