Skip to content
⌘ NSIS Forum Archive

ExecTimeout Plugin

25 posts

LoRd_MuldeR#

ExecTimeout Plugin

I just created an "ExecTimeout" plugin. It will execute and application and wait for the process to exit, just like ExecWait. But in contrast to ExecWait you can specify a timeout. If the application does not exit before the timeout exceeds, it will be terminated. This can be used to make sure your installer won't stall, even if the application doesn't exit for some reason. Plugin, sources and example attached.
LoRd_MuldeR#
Here is a small update. You can now decide whether you want to terminate the process on timeout or leave it alone. Anyway, if the timeout is exceeded, the control will return to the installer immediately.
LoRd_MuldeR#
Another update:
Better method to pass the parameters and simplification of the return value 🙂
Afrow UK#
Sure why not. Otherwise as you add new versions people will never get them. People tend to get the first download in the first post and neglect to find the latest.

Stu
Red Wine#
Besides that Stu said, after 2-3 days of inactivity this thread will get lost between 1000s threads of the forum.
A wiki page is always easy accessible, thus useful to everybody anytime.
Afrow UK#
You should re-upload as ExecTimeout.zip. Notice that re-uploading the file under the same name builds a revision history:


Stu
elllit#
Hi,

hmm... i don't quiet get it...

Where's the difference to nsExec with the /TIMEOUT=x flag?

Anyways, thanks for your support on it LoRd_MuldeR.

Edit:

Here a line of code from my installer:

nsExec::ExecToStack /TIMEOUT=$0 'mycmd'
LoRd_MuldeR#edited
Originally posted by elllit
Hi,

hmm... i don't quiet get it...

Where's the difference to nsExec with the /TIMEOUT=x flag?
If I understand nsExec correctly, then it the /TIMEOUT param will return control to the installer if there was no output by the application for x milliseconds. Also the timeout will be reset when there is new output. So this is only useful for console applications, that write stuff to stdout. It's not useful for GUI applications! Also I'm not sure whether nsExec will terminate the process on timeout or simply leave it alone. My plugin can do both! And it doesn't care about console output, it simply returns control to the installer after a maximum of x milliseconds. So you can be sure that your installer won't stall! Using nsExec an application could constantly write random stuff to stdout and do so until forever. So that application would never timeout and your installer will stall...

Of course my ExecTimeout plugin is useless if you need to capture the console output. It was never intended to do that. I said it's a very simple plugin...


The timeout value is optional.  The timeout is the time in
milliseconds nsExec will wait for output. If output from the
process is received, the timeout value is reset and it will
again wait for more output using the timeout value.
Afrow UK#
I have moved the plug-in download to http://nsis.sourceforge.net/File:ExecTimeout.zip.
If you need to upload revisions upload to that page and put the date as the summary.

Stu
LoRd_MuldeR#
I have uploaded an example that illustrates the difference:
elllit#
Thanks a bunch!

I will move over to your plug-in as it seems less error prone from useage side. At least on my concern.
erik@winepos.com#
Trying to get this plugin to work with the Internet plugin. Here is my code:

${ExecTimeout} 'Internet::GetUrlCode "$2" "logo.jpg" ${VAR_3}' 5000 1 $0

It is not working, any ideas?
LoRd_MuldeR#
Originally Posted by erik@winepos.com View Post
Trying to get this plugin to work with the Internet plugin. Here is my code:

${ExecTimeout} 'Internet::GetUrlCode "$2" "logo.jpg" ${VAR_3}' 5000 1 $0

It is not working, any ideas?
This plug-in is used to execute a child process. The first parameter has to be a command-line! You can not use the plug-in to run a function from another unrelated plug-in. Support for "timeout" functionality has to be implemented in each individual plug-in...
ericpode#
I've been using the ExecTimeout plugin with an older version of NSIS. I updated to version 2.51 of NSIS and found that my script would not compile.

So I downloaded the ExecTimeout.zip demo and found that that generated the same compile error:

InitPluginsDir
File: "myapp.exe"->"$PLUGINSDIR\myapp.exe" [compress] 9015/16384 bytes
MessageBox: 64: "I will start the application with ExecTimeout now. It will time out after 5 seconds!"
DetailPrint: "Executing: "$PLUGINSDIR\myapp.exe""
!insertmacro: ExecTimeout
Invalid command: Timeout::ExecTimeout
Error in macro ExecTimeout on macroline 1
Error in script "C:\Users\Eric\Downloads\ExecTimeout.Demo\TimeoutDemo.nsi" on line 46 -- aborting creation process
Is there a fix for this - or maybe a different plugin that needs to be used with v2.51 ?
LoRd_MuldeR#
Looks like the plug-in function is missing, i.e. the plug-in DLL was not loaded at all.

Are you 100% sure plug-in DLL is in proper "plugins" directory?

Also note that this plug-in is ANSI only, but maybe you use Unicode version of NSIS now? (which actually is a good idea)
ericpode#
Oops - I guess the install of 1.52 must have cleared out the plugins directory. I copied the DLL in there again and it seems to work OK now. Thanks.

this plug-in is ANSI only, but maybe you use Unicode version of NSIS now?
I have no idea. There only seems to be one download for v1.52 - I just installed that.

How would I choose between ANSI and Unicode versions? What would happen if I tried to use the plugin in the ANSI version of NSIS - an error message in compilation or when the installer was run? Is it fairly easy to make a Unicode version of the plugin perhaps if the source code was available?
Anders#
The compiler can't tell if you mismatch plugins. The installer might crash or the plugin call will not work correctly.
vbp13#
Plugin not found, cannot call Timeout::ExecTimeout

I tried to run the example "TestTimeout.nsi"

and got this error.

Plugin not found, cannot call Timeout::ExecTimeout
r2du-soft#
Originally Posted by vbp13 View Post
I tried to run the example "TestTimeout.nsi"

and got this error.

Plugin not found, cannot call Timeout::ExecTimeout
after download and extract the ExecTimeout.zip you must copy Timeout.dll to the nsis patch
you must copy Timeout.dll to:

Windows x32:
C:\Program Files\NSIS\Plugins\x86-ansi

Windows x64:
C:\Program Files (x86)\NSIS\Plugins\x86-ansi

after that you can compile TestTimeout.nsi without error
Nutzzz#
Originally Posted by r2du-soft View Post
after download and extract the ExecTimeout.zip you must copy Timeout.dll to the nsis [path]
I prefer not messing with the NSIS folder for third-party plugins and instead using
!AddPluginDir
Anders#
Originally Posted by Nutzzz View Post
I prefer not messing with the NSIS folder for third-party plugins and instead using
!AddPluginDir
I do this as well. You can also make it automatic so all plug-ins are available for all NSIS installs on your machine.