2012-10-24 93 views
4

基於NSIS的安裝程序將某個.exe文件部署到所有Windows平臺的目標文件夾中。我們最近發現,如果我們在Windows 8上安裝,我們需要部署一個稍微不同的.exe文件版本。適用於不同操作系統的兩個.exe版本

我們不希望有兩個安裝程序。 我們寧願有一個安裝程序「保存」這兩個.exe文件,併爲windows8和其他.exe部署正確的安裝程序。

任何指針我們如何實現這一目標?在安裝時檢測windows8,當我們檢測到時,複製不同版本的.exe文件?

謝謝。

回答

2

通過包含隨NSIS提供的LogicLib.nshWinVer.nsh腳本,您可以非常精確地測試該平臺。

這裏是我使用的功能,我讓安裝應用程序前一些理智檢查:

Function CheckUnsupportedPlatform 
    ${if} ${AtLeastWin95} 
    ${AndIf} ${AtMostWinME} 
     ;NT4 and W95 use the same version number, we can use ${IsNT} if we need precise identification 
     MessageBox MB_OK|MB_ICONEXCLAMATION "Sorry, but your version of Windows is unsupported platform.$\n\ 
Supported platforms are currently 2000/XP/2003/Vista/Seven$\n \ 
      Cannot continue the installation." /SD IDOK 
     abort 
    ${elseIf} ${isWin2008} 
    ${orIf} ${AtLeastWin2008R2} 
     MessageBox MB_OK|MB_ICONINFORMATION "Please note that support for Windows 2008 and Windows 8 is in beta stage.$\n\ 
Supported platforms are currently 2000/XP/2003/Vista/Seven" /SD IDOK 
    ${endif} 
FunctionEnd 

還有更多的可能性,採取的WinVer.nsh更多的例子,頭一看。

1

我有一個與nsis類似的問題,檢測到不同的Windows版本。我剛剛寫了一個三行C++應用程序來調用Windows API來查找操作系統版本,然後將控制檯輸出寫爲字符串。從nsis中,你可以將這個輸出讀入一個變量,然後根據這個變量的值進行切換。

+0

這似乎有點矯枉過正,因爲你可以使用一些已經列入宏執行檢查。 – Seki

0

我知道這是很老,但如果有人有與File命令的問題,這是預期的語法:

!include "WinVer.nsh" 
... 
; The stuff to install 
Section "MyProgram (required)" 
    ${If} ${AtMostWin2003} 
     File /oname=MyFile.exe "MyFile2003.exe" 
    ${Else} 
     File "MyFile.exe" 
    ${EndIf} 
SectionEnd 
相關問題