Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 4th May 2001, 01:38   #1
dbareis
Member
 
Join Date: Apr 2001
Posts: 77
Hi,

Currrently I have a product whose default installation directory defaults to "C:\PROGRAM FILES\SITECOPY".

What I want is to set it to "C:\PROGRAM FILES\SITECOPY" if the user is on Windows NT/2000 (and probably XP) and to "C:\SC" if on DOS versions (95/98/ME). I want this to be the default that is shown in the choose directory dialog so the user can still place the files where they wish.

Can someone please tell me how I can do this.

Thanks for any help,
Dennis
dbareis is offline   Reply With Quote
Old 4th May 2001, 05:29   #2
justin
Moderator Alumni
 
Join Date: Apr 2000
Location: USA
Posts: 315
Sure, just add the following lines to your .nsi file:

code:

Function .onInit
ReadRegStr $0 HKLM "Software\Microsoft\Windows NT\CurrentVersion" SystemRoot
StrCmp $0 "" 0 NoWin9x
StrCpy $INSTDIR C:\SC
NoWin9x:
FunctionEnd



What this does it check for HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRoot, and if it is not empty, it knows it is on Windows NT, and skips the StrCpy line.

Note that if you also want to use InstallDirRegKey (to let the user upgrade easily), and don't want to overwrite that install dir if the user is upgrading, you can use something like:

code:

Function .onInit
StrCmp $INSTDIR "C:\Program Files\SITECOPY" 0 NoWin9x
ReadRegStr $0 HKLM "Software\Microsoft\Windows NT\CurrentVersion" SystemRoot
StrCmp $0 "" 0 NoWin9x
StrCpy $INSTDIR C:\SC
NoWin9x:
FunctionEnd



Which will only change $INSTDIR if the default (C:\program files\SITECOPY) is used..

-Justin
justin is offline   Reply With Quote
Old 4th May 2001, 09:29   #3
dbareis
Member
 
Join Date: Apr 2001
Posts: 77
Excellent, thanks.
dbareis is offline   Reply With Quote
Old 5th May 2001, 00:11   #4
dbareis
Member
 
Join Date: Apr 2001
Posts: 77
Hi Justin,

I was thinking about your response, it solved my main problem (works very well - thanks) but it would be nice if all the main options such as "DirText" could also be accessed as variables. And please if you do this either add $COMSPEC or access to environment variables in general.....

Bye
Dennis
dbareis is offline   Reply With Quote
Reply
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