Archive: nsExec, Possible ExecWait functionality?


nsExec, Possible ExecWait functionality?
  Hello Everyone,

I am using a compiled NSIS Script as a makefile to build installers branded for specific companies. The problem I am having concerns making this script work with a nightly build system.

The problem I am having is that nsExec::Exec, nsExec::ExecToLog and nsExec::ExecToStack, do not wait for the called process to end before returning. This means that the files, even though the build may be successful, will not exist until the compilation has ended, with the downside of the build system thinking they weren't created logging it as an error and continuing.

Are there plans to build an nsExec::ExecWait functionality into nsExec, or is there a way I can get around this? It really would be a nice feature for the plugin.

Cheers!


Are you sure? They should all wait for the process to finish.


Positive. If I have a compiled nsis script running through a command shell like the following:

make/S 

>
that calls another nsis script using nsExec::Exec; ie:


nsExec::Exec '"${NSISDIR}\makensis.exe" $Cmds $Defs "$EXEDIR\$SCRIPT"' 

the prompt immediately returns, and eventually, after the source compiles the new binaries will exist. What I'd like is the prompt to wait until the executable is actually built before exiting.

And what about ExecToLog? That one should put all output in the log before it continues.


I never see a log at all, when running one in the other.....I had posted that odd behaviour earlier..


Post your computer Windows version and what NSIS version you're using for better questions answering in this case.


And a minimal example that reproduces the problem. Maybe the application you are using starts another process.

Note that in this case makensis.exe is probably doing nothing because you should add a backslash after ${NSISDIR}.


Microsoft Windows XP [Version 5.1.2600] With all patches to date 20040519.

NSIS v2.0 (About 2 weeks after Final, since there were two bugs you guys fixed for me) My executable is dated March 30, 2004.

I have include the example as requested, follow the contained readme.txt.

Thanks!


Do you get the same behavior when running another application or only when running makensis?


Just makensis....


Status?


JOOST/1.0 STATUS 430 "BORED AND FORGOT"


nsExec does wait, it's the prompt that doesn't for make.exe because it's not a console application. For example, try using nsExec on make.exe /S.


Well, make.exe was built using NSIS. Is there a way I can make it a console app, so that it will wait as I expect?


Try run it through START.EXE


StrCpy $1 $Windir
StrCpy $2 '$Sysdir\cmd.exe'
IfFileExists '$Windir\START.EXE' +3
StrCpy $1 '$Windir\Command'
StrCpy $2 '$1.com'

nsexec::EXEC '"$2" /c "$1\start.exe" /wait "${NSISDir}\make.exe" /bla /bla'

Originally posted by zimsms
Well, make.exe was built using NSIS. Is there a way I can make it a console app, so that it will wait as I expect?
Only if you intend to make console only (always silent). That would require recompiling without the visible option in config.h and as console application (one of VC's settings). It would be simpler to use start.exe as s793016 mentioned, but outside of an installer and in a batch file.

The Start command specifies the following:

When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt. This new behavior does NOT occur if executing within a command script.

So start cannot be used since nsis compiles as a 32-bit GUI application.

I have resolved this issue by creating a console based app in Visual C#. Only a few lines that monitor the make.exe process and force a wait until the process has finished.

I've included the C# source below. Note this will only work on a machine with the .NET Framework installed, as my build machine does.

Be sure to create a C# Console Based Application, you may need to modify the namespace appropriately.

using System;

>using System.Diagnostics;
>using System.ComponentModel;


>namespace ExecWait
>{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Execute
{
/// <summary>
/// The main entry point for the application.
/// </summary>
***91;STAThread***93;
staticvoid Main(string***91;***93; args)
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "Make.exe";
myProcess.StartInfo.Arguments = "/S";
myProcess.Start();

myProcess.Wait*****it();
}
}
}