I am trying to install 7-Zip.msi using msiexec. Whilst I can execute the msi using the following nsis command it defaults installation to C:\Program Files
ExecWait '"msiexec" /passive /i "$OUTDIR\<msi filename>.msi"'
I cannot find a way of specifying a custom destination directory for the install.
msiexec documentation suggests I can use TARGETDIR. So I tried the below
SetOutPath "C:\Software\7-Zip"
DetailPrint "Installing 7-Zip to $OUTDIR"
ExecWait '"msiexec" /passive /i "$OUTDIR\7-Zip.msi" TARGETDIR="$OUTDIR"'
But when I run the nsis exe I get no error, but 7-Zip has not been installed to the C:\Software\7-Zip directory.
Does anyone know how you specify a target installation directory when using msiexec?
ExecWait '"msiexec" /passive /i "C:\Temp\7-Zip.msi" INSTALLDIR="$OUTDIR"'
Using INSTALLDIR solved the issue. Seems as though INSTALLDIR is a property specific to the 7-Zip.msi. Some msi files use TARGETDIR.
Related
I'm creating one installer. I need VC++2013 runtime for my applicaiton. So i'm checking and if not found VC++ runtime i'm installing it from my installer.
To do that, I'm copying VC++ runtime exe into programfiles/myapplication and running it using
ExecWait '"$INSTDIR\vc.exe" /passive /norestart' $0
Delete "$INSTDIR\vc.exe"
But the problem is vc.exe is not getting deleted. It remains in programfiles/myapplication folder.
I use IfErrors command and found that error occurs.
Please suggest me how to solve this
ExecWait always waits until the child process ends but just because the process has ended does not mean you can delete the .EXE file. It should ideally mean that but in some cases Explorer or Anti-Virus will keep files locked for a couple of seconds. Without more information it is hard to say why it can't be deleted, Process Monitor will probably provide some clues.
You could try
ExecWait '"$INSTDIR\vc.exe" /passive /norestart' $0
Sleep 2500
Delete "$INSTDIR\vc.exe"
but since you are just going to delete it anyway, I would suggest extracting it somewhere else that NSIS will try to clean up for you instead:
Section
InitPluginsDir
File "/oname=$PLUGINSDIR\vc.exe" "c:\myredistfiles\vc.exe"
ExecWait '"$PLUGINSDIR\vc.exe" /passive /norestart' $0
SectionEnd
Trying to run a batch file at the end of an installation, everything works great except this file won't run.
section "Startup"
Exec '"$0" /C "C:\Program Files\placeholder\startup\startup.bat"'
sectionEnd
Everything gets deposited in the right spot, using absolute pathing to call this. I asked for administrator privileges at the start,
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
Just copying from the example NSIS installer provided here
The file is there so I must be making a mistake with the file path or missing some parameter. Been trying a lot of permutations like nsExec but not sure my mistake. Hopefully this is a simple mistake and will aid others in the same boat at some time.
Without more information I would guess that this is a 64-bit Windows machine and filesystem redirection is causing your 32-bit installer to access the wrong program files directory.
The code you posted is also problematic because we don't know what $0 is. I assume you failed to post the code where it expands %comspec%. To rule out this, replace $0 with $sysdir\cmd.exe.
Ideally your installer should extract the batch file to the destination directory:
Section
SetOutPath $InstDir
File batch.bat
ExecWait '"$sysdir\cmd.exe" /C if 1==1 "$InstDir\batch.bat"'
SectionEnd
If you must access the 64-bit folder you can disable the redirection but this is not recommended:
!include x64.nsh
Section
${DisableX64FSRedirection}
ExecWait ... $ProgramFiles64\...
${EnableX64FSRedirection}
SectionEnd
I think that you should give us more information to solve this problem.
Based on current information, I guess there are two reasons:
"C:\Program Files" is a path for 64-bit programs, but NSIS installer is a 32-bit program, so this path will be redirected to "C:\Program Files (x86)". You can use the solution from Anders to solve it.
Your batch file may contains relative paths. When you run your batch file from the NSIS installer, your working directory is not as same as your batch file. Due to this, some command cannot run correctly. You can use %~dp0 to solve it.
I have many files and folders to be added to my installation package. I tried command
File /nonfatal /a /r "C:\Users\test\hdp*"
and
File /nonfatal /a /r "C:\Users\test\hdp\"
but it didn't create the output file(.exe). I also tried with zip file (means created zip file of hdp folder) and add it into package but the same issue i am facing with zip file also.
hdp folder size is 250MB only.
In documentation also no option is mentioned to add folder. Can someone suggest how to add these folder and subfolders to the package?
You should start with Example1.nsi and understand all of its instructions before trying to write a real installer.
OutFile "myinstaller.exe" ; Name of generated installer .exe
InstallDir "$Desktop\MyApp" ; Change this
Page Directory
Page InstFiles
Section
SetOutPath $InstDir
File /r "c:\users\test\myfilestoinstall\*.*" ; Change this
SectionEnd
I'm new to NSIS and creating one installer for our project.
The requirement is: there are 1 folder and 2 exes needs to be installed as part installation. These exes are created using nsis (Y.exe, Z.exe). These exes should be installed in different destination folder. I've tried this two approches:
Approach 1:
in script these variables assigned
RUN_Y C:\Installer\misc_exe\y.exe
RUN_Z C:\Installer\misc_exe\y.exe
Y_INSTALL_DIR INSTDIR\Y\ # INSTDIR is specified by user during folder installation
Z_INSTALL_DIR INSTDIR\Z\ # INSTDIR is specified by user during folder installation
# calling this at the time exe installation
setoutpath SetOutpath "${Y_INSTALL_DIR}"
ExecWait '"${RUN_Y}"'
setoutpath SetOutpath "${Z_INSTALL_DIR}"
ExecWait '"${RUN_Z}"'
Problem is, the destination folder is always coming as C:\Installer\misc_exe\ , whereas it should be C:\Y\. How can I fix it?
Approach 2:
While creating the zipped folder to exe, I gave destination folder as $INSTDIR/Y/ and $INSTDIR/Z/, and I think, this $INSTDIR is taken from the 1st folder installation. But, its not working that way.
can anyone help with me with how can I do specific folder installation?
Thanks in advance.
I am not sure what are you trying to do but to set target directory use
InstallDir "C:\Y\"
command.
I'm having some path problems in the default installation. My code below:
http://pastebin.com/7vrCuLiZ
And my problem is that the default path to install is "C:\Program Files (x86)\Advanlab\DISK1\Common\Borland Shared\BDE\" instead of "C:\Program Files (x86)\Advanlab"
https://www.dropbox.com/s/vfoxytj1sbvqs5a/helpnsis.png
Thanks for your help :)
EDIT:
It only happens if the folder Advanlab already exist :s
The InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" command is probably picking up this directory, try InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
Have you set the default installation directory in your NSIS script?
; The default installation directory
InstallDir $PROGRAMFILES\xxx