Skip to content
⌘ NSIS Forum Archive

Can't run program with parameter

6 posts

brettg#

Can't run program with parameter

Hello. I want to give the option of running the program with a command line param at the end of the install. So I define these macros.

!define MUI_FINISHPAGE_RUN "$INSTDIR\SqlitePlus.exe"
!define MUI_FINISHPAGE_RUN_PARAMETERS "$INSTDIR\Samples\Db\Northwind.db"

The problem is, if there are any spaces in the INSTDIR (like "Program Files"), the parameter is not passed correctly. How can I make it work?

thank you
-brett
deguix#
Use the command GetFullPathName /SHORT. It will convert a long path to its short path format.

But as you can't do this at compile time, you can use this code, but I'm unsure if this will work because I didn't test it:


;... other MUI_PAGE_FINISH defines
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ShortenPath

!insertmacro MUI_PAGE_FINISH

Function ShortenPath

!undef MUI_FINISHPAGE_RUN_PARAMETERS

GetFullPathName /SHORT $0 "$INSTDIR\Samples\Db\Northwind.db"

!define MUI_FINISHPAGE_RUN_PARAMETERS $0

FunctionEnd
brettg#
Thank you. I will try it.

While I have someones attention, I would very much like to know if there is a way to automatically handle usage counting for shared DLLs. As you must know, Windows has a mechanism to keep count of shared DLLs, so setup programs can know when to unregister and delete the shared DLL. I can't find any info on it.

thanks in advance
-brett
brettg#
I tried it but I can't get it to work. Why doesn't the MUI_FINISHPAGE_RUN_PARAMETERS macro just work? You should be using ShellExecute and you should just quote the parameter. Then it would work. Is there any chance of getting this fixed quicly?
deguix#
This one I'm more certain that will work:

  ;... other MUI_PAGE_FINISH defines
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ShortenPath

!insertmacro MUI_PAGE_FINISH

Function ShortenPath

!insertmacro MUI_INSTALLOPTIONS_READ $0 "ioSpecial.ini" "Field 4" "State"

StrCmp $0 1 0 +4

GetFullPathName /SHORT $0 "${MUI_FINISHPAGE_RUN_PARAMETERS}"

Exec '"${MUI_FINISHPAGE_RUN}" "$0"'

Quit

FunctionEnd
Takhir#
Shared DLLs - Registry

HKEY_LOCAL_MACHINE
SOFTWARE
Microsoft
Windows
CurrentVersion
SharedDlls

I found this in MSDN Platform SDK as "Usage counting"
Use DLL path/file as value name in RegQueryValue() call.