With NSIS I'm creating an installer for a selfmade software suite. This installer needs to run three .exe files.
With
Exec "Execute1.exe"
Exec "Execute2.exe"
Exec "Execute3.exe"
I run all those files. The problem is all files are running parallel. I want to run the files successively - first Execute1.exe, then Execute2.exe and Execute3.exe at the end.
Use ExecWait instead:
ExecWait command [user_var(exit code)]
Execute the specified program and wait for the executed process to quit.
ExecWait "Execute1.exe"
ExecWait "Execute2.exe"
ExecWait "Execute3.exe"
ExecWait is what you are looking for. I'd link to documentation, but online links seem to be broken.
File "${MSVSREDIST}\${MSVSREDISTFILE2008}"
ExecWait '"${ExtractPath}\${MSVSREDISTFILE2008}" /q'
File "${MSVSREDIST}\${MSVSREDISTFILE2010}"
ExecWait '"${ExtractPath}\${MSVSREDISTFILE2010}" /passive /norestart'
File "${DOTNET}\${DOTNETFILE}"
ExecWait '"${ExtractPath}\${DOTNETFILE}" /passive /norestart'
Related
I want to check the output of encrypted password using java utility jar file for that I added 5-second timeout
ExecWait '"java.exe" -Ddata.dir="C:\example" -jar "encrypt.jar" "DecryptPassword" "5q/wsfafLx8vcsdsd==" "C:\temp.properties" & timeout 5'
but my cmd window gets closed automatically? how to stop the cmd window for 5 seconds to check output?
& is not something that just works everywhere, it only works in the command interpreter. Add cmd.exe /c if 1==1 to the start of the ExecWait string.
A better solution is to use the nsExec plug-in to get the result from stdout.
I have a repo that runs a Windows .bat file on build. I'd like it to not do that when I'm on Linux. Is there a trick I can put in the .bat file, or do I have to make the build system deal with this?
Found a simple solution, just put the following lines at the head of the .bat file:
rem () { echo "Not running prebuild.bat on Linux"; exit 0; }
rem skip prebuild if executed by bash
In my Inno Setup script, I need to execute a command that generates temp files that are to be copied in the [Files] section. I have tried the following:
; cd to the directory of the Inno Setup script and execute a python file
#expr Exec('cmd /C "cd /d %cd% & C:\Python34\python.exe run.py"','','',1,SW_HIDE)
This does not seem to execute as I do not see the files created, which can obviously not be included in the installer.
Along the same lines, how would I execute a command when complete to delete these temp files?
Edit I did execute the cmd by hand and validated that it works
It should be:
#expr Exec('cmd.exe', '/C "cd /d %cd% & C:\Python34\python.exe run.py"','',1,SW_HIDE)
The cmd.exe is the process you are executing, the rest are arguments.
Though even better would be to do without cmd.exe as you do not need it actually:
#expr Exec('C:\Python34\python.exe', 'run.py','c:\startupfolder',1,SW_HIDE)
See Inno Setup Preprocessor: Exec.
Though personally, I'd create a batch file that first runs the Python and then runs Inno Setup compiler. It's way easier and more understandable.
I can use #if exist to test a file does exist or not, but did not find the document via Google. For example, in my makefile for nmake ;
clean:
#if exist $(BIN_DIR) rmdir /S /Q $(BIN_DIR)
#if exist $(OBJ_DIR) rmdir /S /Q $(OBJ_DIR)
You won't find any documentation regarding "#if exist" in nmake documentation. These are plain shell commands.
So just open a cmd window and at the prompt enter "help if". By the way the "#" sign suppresses the echo in a shell script.
Thats's why most of .bat scripts start with "#echo off".
You can find nmake documentation here (I'm surprised you did not find it):
VS 2012:
http://msdn.microsoft.com/en-us/library/dd9y37ha.aspx
VS 2010:
http://msdn.microsoft.com/en-us/library/dd9y37ha(v=vs.100).aspx
VS 2008:
http://msdn.microsoft.com/en-us/library/dd9y37ha(v=vs.90).aspx
Earlier versions are also available but nmake has not changed much.
Variables that are accessed using the $(VARNAME) syntax are either environment variables, or variables declared inside the makefile itself.
Here's a really simple makefile that declares a variable, and the single rule (ALL) ouputs the PATH (from the environment) then the locally-declared variable.
MY_VAR=12345
ALL:
#echo $(PATH) $(MY_VAR)
I'm creating my first NSI script and I'm just wondering if I can execute a command-line command from NSIS or should I just execute a batch file? I don't really know where to begin and other similar topics have gone a little over my head.
I would recommend taking a look at the nsExec plugin. I just recently had a situation where I needed to ping a server from inside an NSIS script, and the following code worked perfectly for me.
nsExec::Exec '"C:\Windows\System32\PING.EXE" $URL'
The benefit of using nsExec is that it executes the command without making a dos box pop up on your screen. The return value is pushed onto the stack, and there are a couple different ways that you can access the output of the program as well (if any exists).
There isn't a whole lot of information about the plugin on the NSIS website that I could find, but the following link should get you started in the right direction:
http://nsis.sourceforge.net/Docs/nsExec/nsExec.txt
Edit:
I noticed you asked specifically about a COPY command which is an internal DOS command, meaning that you won't be able to execute it like I did with ping. I may be mistaken but you shouldn't need to use any outside programs to carry out basic commands like this. You should be able to replicate most of the internal commands using NSIS commands.
For Example to copy a file (or multiple files) use the NSIS command: CopyFiles
The NSIS Scripting Reference is your friend :) (So is ctrl+f)
Try using exec command http://nsis.sourceforge.net/Docs/Chapter4.html:
4.9.1.2 Exec
command
Execute the specified program and continue immediately. Note that the file specified must exist on the target system, not the compiling system. $OUTDIR is used for the working directory. The error flag is set if the process could not be launched. Note, if the command could have spaces, you should put it in quotes to delimit it from parameters. e.g.: Exec '"$INSTDIR\command.exe" parameters'. If you don't put it in quotes it will not work on Windows 9x with or without parameters.
Exec '"$INSTDIR\someprogram.exe"'
Exec '"$INSTDIR\someprogram.exe" some parameters'
We can launch a command-line command from NSIS, get the returned value and further develop the installation logic based on that.
Example: Let's say we need to get the installed clang compiler version. To get the version we have to launch:
clang --version
In NSIS we do this using ExecToStack:
nsExec::ExecToStack 'cmd /c "clang --version"'
Pop $0
Pop $0
;now we have the version in $0
Warning: Only the second Pop $0 gets the response that we want, in this case the clang version. The first Pop $0 grabs the exit code.