Go Back   Winamp Forums > Developer Center > NSIS Discussion

 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 3rd October 2009, 11:05   #1
jan007
Junior Member
 
Join Date: Oct 2009
Posts: 2
PATH is erased/replaced

Hi,
I've made a commandline utility (.exe) that depends on a couple of dll's.
After looking for some kind of packer that would allow me to let users download and use a single (working) exe (with the dll's included) it seems that is impossible.
So someone pointed me to NSIS, which is a great tool, although I don't actually need to install software.

Crucial in my setup is that users don't have to add the directory with the exe to their environmental PATH variable. NSIS does a great job with this but in my case it erased my entire PATH even though I used A(ppend).
Gladly enough I read a lot of related posts before I tried, so I made a backup of my PATH.
But I can't seem to find a solution to this problem. My PATH contains 1081 characters and slimming it down does solve the problem. But I can't ask my users to do that or otherwise I could just as well offer a zip and make them add the dir to their PATH themselves.

1)Is there a 'real' solution to this problem?
2)Can I otherwise somehow count the characters of their PATH variable and show a warning that their PATH will not be updated and that they will (still) have to add it themselves manually and show/link to a manual of how to do this?
3)The directory which should added to the PATH variable is now hardcoded in my nsi script, but when people choose to 'install' in another directory this won't be correct. How can I retrieve what 'custom' directory they choose and use that dir to append to their PATH?
4)As I said before: I'm not actually installing software, it's more like saving into a dir and setting up the PATH. So, can I leave out all the registry stuff from the example.nsi or can this be usefull for other things such as an uninstaller which in my case would be just to remove the dir+contents and the PATH var?

I'm using NSIS 2.45 and Windows XP.

Thanks in advance!

Although the provided examples seem quite easy to change to reflect my setup I'm still posting it to make sure it does not contain unwanted, unneeded or even dangerous stuff.

code:
!include EnvVarUpdate.nsh
Name "MyApp"
OutFile
"MyApp_installer.exe"
InstallDir $PROGRAMFILES\MyApp
InstallDirRegKey HKLM
"Software\MyApp" "Install_Dir"
RequestExecutionLevel admin

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

Section
"MyApp (required)"
SectionIn RO

SetOutPath $INSTDIR

File "MyApp.exe"
File "gc.dll"
File "neko.dll"
File "regexp.ndll"
File "std.ndll"
File "zlib.ndll"
File "LICENSE"
File "neko_source_download.txt"
File "howto.txt"

WriteRegStr HKLM SOFTWARE\MyApp
"Install_Dir" "$INSTDIR"

WriteRegStr HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "DisplayName" "MyApp"
WriteRegStr HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "NoModify" 1
WriteRegDWORD HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "NoRepair" 1
WriteUninstaller
"uninstall.exe"
${EnvVarUpdate} $0
"PATH" "A" "HKLM" "C:\Program Files\MyApp"
SectionEnd

Section
"Start Menu Shortcuts (uninstaller)"
CreateDirectory
"$SMPROGRAMS\MyApp"
CreateShortCut
"$SMPROGRAMS\MyApp\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut
"$SMPROGRAMS\MyApp\howto.lnk" "$INSTDIR\howto.txt" "" "$INSTDIR\howto.txt" 0
SectionEnd

Section
"Uninstall"
DeleteRegKey HKLM
"Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp"
DeleteRegKey HKLM SOFTWARE\MyApp

Delete $INSTDIR\MyApp.exe
Delete $INSTDIR\uninstall.exe
Delete $INSTDIR\gc.dll
Delete $INSTDIR\neko.dll
Delete $INSTDIR\regexp.ndll
Delete $INSTDIR\std.ndll
Delete $INSTDIR\zlib.ndll
Delete $INSTDIR\LICENSE
Delete $INSTDIR\neko_source_download.txt
Delete $INSTDIR\howto.txt

Delete
"$SMPROGRAMS\MyApp\*.*"

RMDir
"$SMPROGRAMS\MyApp"
RMDir
"$INSTDIR"

${un.EnvVarUpdate} $0
"PATH" "R" "HKLM" "C:\Program Files\MyApp"
SectionEnd


Cheers,

Jan

Last edited by jan007; 3rd October 2009 at 11:28.
jan007 is offline   Reply With Quote
 
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump