For copy file i use (code below) its work properly.
Section "one"
CreateDirectory $EXEDIR\dst
CopyFiles $EXEDIR\*.* $EXEDIR/dst
SectionEnd
When i use $PROGRAMFILES(only change the destination path) it create directory but copy doesn't work.
Section "two"
CreateDirectory $PROGRAMFILES\dst
CopyFiles $EXEDIR\*.* $PROGRAMFILES/dst
SectionEnd
where is the problem?
/ is not the path separator on Windows, use \. / is supported in a lot of places but not everywhere.
It might also be failing if you don't have write access to that folder so make sure you have RequestExectionLevel Admin in your script.
The only way to know for sure is to monitor the installer with Process Monitor...
Related
Problem
I have multiple files in very similarly structured folders that I want to install in one common folder.
I can do this by manually specifying each file I want to add, like so:
SetOutPath "$INSTDIR\Final\Destination"
File /r ".\ParentFolder\Folder1\Same\Path\For\All\Thing1.ext"
File /r ".\ParentFolder\Folder2\Same\Path\For\All\Thing2.ext"
File /r ".\ParentFolder\Folder3\Same\Path\For\All\Thing3.ext"
File /r ".\ParentFolder\Folder4\Same\Path\For\All\Thing4.ext"
File /r ".\ParentFolder\Folder5\Same\Path\For\All\Thing5.ext"
However, there are 50+ of these files, and they are likely to change, so I'd prefer to do this in a way that won't require editing the NSIS in the future.
What I have Tried
I tried putting in wildcards, like so:
SetOutPath "$INSTDIR\Final\Destination"
File /r ".\ParentFolder\*\Same\Path\For\All\*.ext"
However, I get the message
File: ".\ParentFolder\*\Same\Path\For\All\*.ext" -> no files found.
Question
Is there something wrong with using multiple wildcards * in my File query?
What would be the correct way to query multiple files in different folders?
You can't put wildcards anywhere, only in the filename unfortunately.
What you can do however is to use !system to execute a batch file (or any other command or application) that writes NSIS instructions to a file you can !include:
Section
SetOutPath $InstDir
!tempfile folders ; temporary .nsh
!system 'for /D %A in (.\ParentFolder\*) do #>>"${folders}" echo File /r "%~A\Same\Path\For\All\*.ext"'
!include "${folders}"
!delfile "${folders}"
SectionEnd
I would add some command line to customize my NSIS intaller. I already read some topics, I know I must use ${GetParameters} and ${GetOptions}. But the NSIS script is very long do I put him somewhere in the OnInit function or in a section at the beginning of the script ?
I want, for example, to add an --quiet command line which display all the pages except the license( something which seems to /S), I want to try something like that:
Var DisplayAllPages
Var DisplayLicense
${GetParameters} "quiet"
${GetOptions} "quiet" "--quiet"=DisplayLicense
But I don't Know where can I write
You can use ${GetParameters} and ${GetOptions} in any function and/or section.
Only .onInit and sections are executed when the installer is started with /S so if you wish to turn silent mode off you need to put the code in .onInit.
If you are storing the result in a global variable then .onInit is also a good place to call them so that the information is available to the rest of the installer.
I want to append a default directory to my INSTALL directory always internally.
I have set it by default but if user change the directory then it not works and installed the files in the folder that user selected.
So I need append a folder ( Product name ) always internally and it can be append with the user's selected path.
Like if user selected "C:\Program Files\My Folder" then the installation should be in path "C:\Program Files\My Folder\ProductName"
Should work with the silent as well.
Can someone please advise on this.
Section MyFirstSection
StrCpy $InstDir "$InstDir\ProductName" ; Force extra sub-directory
; ...
SectionEnd
However, the recommended way to do this is to just use InstallDir without a ending backslash:
Note that the part of this string following the last \ will be used if the user selects 'browse', and may be appended back on to the string at install time (to disable this, end the directory with a \ (which will require the entire parameter to be enclosed with quotes).
I am using Windows version of NMAKE. I would like to check for file existence in a make file. If it exists I need to delete it. Here is my code:
!IF EXIST ("C:\ABC.XML")
#del ABC.XML
!ELSE
#echo "FILE DOESN'T EXIST
!ENDIF
The above code is not working. I could not figure it out the problem. Please help.
Your code doesn't work because !IF, !ELSE and !ENDIF are a preprocessing directives and the result of preprocessing must produce a valid makefile. Commands are only allowed as part of what Microsoft calls a description block which are required to start with a dependency line with one or more targets and zero or more dependents.
You can get around this by executing your commands during the preprocessing stage by including them in a preprocessing directive surrounded by brackets ([]). Something like this:
!IF EXIST(C:\ABC.XML)
! IF [del C:\ABC.XML]
! ENDIF
!ELSEIF [echo FILE DOESN'T EXIST]
!ENDIF
The second !IF and the !ELSEIF directives are used to provide a context for the commands so they're executed during the preprocessing phase.
However I think you'd probably be better moving the del command to a description block where it's actually needed. For example if file ABC.XML needs to be deleted before it can be rebuilt, use something like this:
ABC.XML: ABC.CSV
-rem The csv2xml translator requires that the XML file not already exist
-#del ABC.XML 2> NUL
csv2xml ABC.CSV ABC.XML
I am new to NSIS i am trying to execute an executable while installation similar to pre request. I tried the below code which copies the exe to the installation path but it is not executing it.
Section "example" example
SetOutPath "$INSTDIR"
File "setup.exe"
Exec "$INSTDIR\setup.exe"
BringToFront
SectionEnd
The answer from Seki is mostly correct, I'd just like to add that the correct syntax for Exec/ExecWait is always Exec '"c:\path\app.exe" param1 "par am2" param3'
Parameters are of course optional but the path to the app should always be quoted, not just because in your case where $INSTDIR could contain spaces but at least on Win9x it will fail no matter what if you don't quote (According to the NSIS manual)
If the spaces/lack of quotes is not the issue then there are a couple of other things you might want to look into:
$OUTDIR is the working directory for the new process (SetOutPath sets this)
Missing dll's etc (Check with Process Monitor)
Do the $INSTDIR variable maps to a directory whose name contains spaces? If so, you should add simple quotes to include the double quotes into the Execargument :
Exec '"$INSTDIR\setup.exe"'