一个NSIS脚本可以从微软下载.NET和DirectX,然后安装吗?
我不想在我的安装程序中包含这些安装程序,因为它们太大了。
以下是代码:
Function GetDotnet ;// looks for local copy before downloading, returns path in $0
Pop $0
${If} ${FileExists} "$InitDir\dotnetfx35.exe"
StrCpy $0 "$InitDir\dotnetfx35.exe"
${ElseIf} ${FileExists} "$InitDir\dotnetfx35setup.exe"
StrCpy $0 "$InitDir\dotnetfx35setup.exe"
${Else}
Call DownloadDotnet
StrCpy $0 $0
${EndIf}
Push $0
FunctionEnd
Function DownloadDotnet ;// downloads .Net, returns download path in $0
NSISDL::download "${DotnetDownloadUrl}" "${TempDir}\dotnetfx35setup.exe"
Pop $0
${If} $0 == "cancel"
Quit
${EndIf}
StrCpy $0 "${TempDir}\dotnetfx35setup.exe"
Push $0
FunctionEnd
Function InstallDotnet ;// kicks off the .Net installer
Pop $0
Push $1
ExecWait '"$0" /norestart' $1
FunctionEnd
对于DX,您可以使用dxwebsetup.exe作为引导程序。它是一个小型安装程序,可以扫描用户的系统,然后下载所需的组件:
http://www.microsoft.com/downloads/details.aspx?FamilyID=2da43d38-db71-4c1b-bc6a-9b6652cd92a3&displaylang=en
不确定是否有类似的网络安装程序适用于常规的.NET框架,但至少这是解决问题的一半。