Archive: Install Different Files for Different OS, Possible?


Install Different Files for Different OS, Possible?
Question, I have drivers to install but want a different *.dll to install for a different OS or problems may occur. Basically, I have the code below, then copy files to the users computer but I only want to copy the XP driver files if the user has XP, the Win98SE files if the user has Win98SE, etc. Any help?

I have this;
;--------------------------------------
; GetWindowsVersion
;
; Based on Yazno's function, http://yazno.***********/powerpimpit/
; Updated by Joost Verburg
;
; Returns on top of stack
;
; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003)
; or
; '' (Unknown Windows Version)
;
; Usage:
; Call GetWindowsVersion
; Pop $R0
; ; at this point $R0 is "NT 4.0" or whatnot

Function GetWindowsVersion

Push $R0
Push $R1

ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion

IfErrors 0 lbl_winnt

; we are not NT
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber

StrCpy $R1 $R0 1
StrCmp $R1 '4' 0 lbl_error

StrCpy $R1 $R0 3

StrCmp $R1 '4.0' lbl_win32_95
StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98

lbl_win32_95:
StrCpy $R0 '95'
Goto lbl_done

lbl_win32_98:
StrCpy $R0 '98'
Goto lbl_done

lbl_win32_ME:
StrCpy $R0 'ME'
Goto lbl_done

lbl_winnt:

StrCpy $R1 $R0 1

StrCmp $R1 '3' lbl_winnt_x
StrCmp $R1 '4' lbl_winnt_x

StrCpy $R1 $R0 3

StrCmp $R1 '5.0' lbl_winnt_2000
StrCmp $R1 '5.1' lbl_winnt_XP
StrCmp $R1 '5.2' lbl_winnt_2003 lbl_error

lbl_winnt_x:
StrCpy $R0 "NT $R0" 6
Goto lbl_done

lbl_winnt_2000:
Strcpy $R0 '2000'
Goto lbl_done

lbl_winnt_XP:
Strcpy $R0 'XP'
Goto lbl_done

lbl_winnt_2003:
Strcpy $R0 '2003'
Goto lbl_done

lbl_error:
Strcpy $R0 ''
lbl_done:

Pop $R1
Exch $R0

FunctionEnd

Section "Test CopyFiles"

SectionIn 1 2 3

SetOutPath $INSTDIR\cpdest
CopyFiles "$WINDIR\*.ini" "$INSTDIR\cpdest" 0
;Then if they have XP, CopyFiles"$WINDIR\winxp.ini" "$INSTDIR\winxp"
;Then if I have WinMe, CopyFiles"$WINDIR\winME.ini" "$INSTDIR\winME"

SectionEnd


Thanks, or if anyone has an example program installing driver files specific to an operating system, let me know.


Call GetWindowsVersion
Pop $0
StrCmp $0 "XP" xp
StrCmp $0 "ME" me other
xp:
CopyFiles "$WINDIR\winxp.ini" "$INSTDIR\winxp"
Goto done
me:
CopyFiles "$WINDIR\winME.ini" "$INSTDIR\winME"
Goto done
other:
DetailPrint "not xp or me"
done:
Please attach large scripts next time.

Works but is not OS specific
OK, I tried what you said, I have the above get windows version script and did whats below. The only problem is the installer works but on my WinXP system, it still installs All files, any help again is appreciated, thanks.

;------------------------------

Section "1" Sec1

SectionIn 1 5
SetOverwrite ifnewer
SetOutPath "$INSTDIR\USB Drivers"
Call GetWindowsVersion
Pop $0
StrCmp $0 "XP" xp other
StrCmp $0 "ME" me other
StrCmp $0 "98" ne
StrCmp $0 "2K" tk
StrCmp $0 "95" nf
xp:
CopyFiles "${NSISDIR}\XP" "$INSTDIR\USB Drivers\XP"
Goto done
me:
CopyFiles "${NSISDIR}\ME" "$INSTDIR\USB Drivers\ME"
Goto done
ne:
CopyFiles "${NSISDIR}\98" "$INSTDIR\USB Drivers\98"
Goto done
tk:
CopyFiles "${NSISDIR}\2K" "$INSTDIR\USB Drivers\2K"
Goto done
other:
CopyFiles "${NSISDIR}\All" "$INSTDIR\All"
Goto done
nf:
DetailPrint "Windows 95 is not supported"
done:

SectionEnd


I mean it installs ALL files on WinXP, not just the XP ones, thanks.


StrCmp $0 "XP" xp other
StrCmp $0 "ME" me other
StrCmp $0 "98" ne
StrCmp $0 "2K" tk
StrCmp $0 "95" nf
you currently have it set to go to XP if its xp else ditch out and go to other.... ie it will NEVER even evaluate the other possibilities should be:

StrCmp $0 "XP" xp
StrCmp $0 "ME" me
StrCmp $0 "98" ne
StrCmp $0 "2K" tk
StrCmp $0 "95" nf other

As for it not pulling it out properly under XP i would suggest trying to work out what it is returning before you panic a quick

Messagebox MB_OK $0
Inserted after getwindowsversion should cast some light here... I cant remember how this behaves with XP home / Pro ...