CreateShortCut issue - nsis

I want to create a shortcut for a webpage which if i start it will start with the specified browser. Normaly you just have to right click on your desktop and create shortcut with this parameter :
example:
"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" http://google.com
Please help me i do not no how to remake it in NSIS.
So far i have:
Section
CreateShortCut "$SMPROGRAMS\html\google.lnk" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe http://google.com"
SectionEnd
As you can see the main problem that i cannot insert more " sign in this expression

A URL shortcut is not actually a .lnk, just do:
WriteINIStr "$SMPROGRAMS\html\google.url" "InternetShortcut" "URL" "http://google.com"
You can also set a custom icon.
If you want to force it to open in a specific browser (not a good idea) you can do:
CreateShortCut "$SMPROGRAMS\html\google.lnk" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "http://google.com"

Related

NSIS - How to install multiple files with similar folder structures using a single command?

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

Hard symbolic link: Specifiy "Start in:" and Parameters

I'm using
mklink /h "C:\Shortcut.exe" "C:\Real.exe"
to create a hard symbolic file link.
However, I don't see how I could specify the "Start in:" property for the Target file or parameters.
Is there a way to do that?
You can create Shortcut.bat (instead of a link) and write below command into it:
call "absolute\path\of\your\excecutable" %*
Example:
#call "C:\Program Files (x86)\GnuWin32\bin\openssl.exe" %*
Save above lines in openssl.bat everywhere you need a shortcut.

Fail to copying file in NSIS?

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...

How to add a default folder always with target installation using NSIS

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).

Exec not working in NSIS installer

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"'

Resources