如何静默安装dot net framework 4.0 [英] How to install dot net framework 4.0 silently

查看:386
本文介绍了如何静默安装dot net framework 4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在visual studio 2010中创建了一个设置。如果他不在用户机器中,我想要静态安装dot net framework。我在NSIS中创建了脚本,但我无法添加此框架4.0。我在谷歌找到了这么多剧本,但没有人为我带来更多好处。任何人都可以告诉我如何使用以上框架的静音安装进行设置





[已添加]



你能不能告诉我如何以及在哪里编写程序来静默安装dot net framework 4.0。我使用我的设置创建了这个脚本但它不能正常工作



===================== =============

;用法

; 1从.onInit函数调用SetupDotNetSectionIfNeeded

;此功能将检查是否需要的版本

;安装了更高版本的.NETFramework。

;如果未安装.NET,则选择安装dotnetfx的部分。

;如果安装了.NET,则取消选择安装dotnetfx的部分。



#!define SF_USELECTED 0

#!define SF_SELECTED 1

#!定义SF_SECGRP 2

#!定义SF_BOLD 8

#!定义SF_RO 16

#!定义SF_EXPAND 32

###############################



!定义DOT_MAJOR 4

!定义DOT_MINOR 4



!定义PRODUCT_NAMEShiv

!定义PRODUCT_VERSION1.0

!定义PRODUCT_PUBLISHERIdha

!define PRODUCT_UNINST_KEYSoftware\Microsoft\Windows\CurrentVersion\Uninstall\ $ {PRODUCT_NAME }

!定义PRODUCT_UNINST_ROOT_KEYHKLM



; MUI 1.67兼容------

!包括MUI.nsh



; MUI设置

!定义MUI_ABORTWARNING

!定义MUI_ICON$ {NSISDIR} \Contrib\Graphics\Icons\modern-install.ico

!定义MUI_UNICON$ {NSISDIR} \Contrib\Graphics \ Icons\modern-uninstall.ico



;欢迎页面

!insertmacro MUI_PAGE_WELCOME

;目录页

!insertmacro MUI_PAGE_DIRECTORY

; Instfiles页面

!insertmacro MUI_PAGE_INSTFILES

;完成页面

!insertmacro MUI_PAGE_FINISH



;卸载程序页面

!insertmacro MUI_UNPAGE_INSTFILES



;语言文件

!insertmacro MUI_LANGUAGE英语



; MUI结束------



名称$ {PRODUCT_NAME} $ {PRODUCT_VERSION}

OutFileSetup.exe< br $>
InstallDir$ PROGRAMFILES \Shiv

ShowInstDetails show

ShowUnInDDetails show



部分MainSectionSEC01

SetOutPath$ INSTDIR

SetOverwrite ifnewer

文件D:\ SHIV \Projects\PlayGame \Setup1 \Debug \Setup1.msi

SectionEnd



部分-AdditionalIcons

CreateDirectory $ SMPROGRAMS \Shiv

CreateShortCut$ SMPROGRAMS \Shiv \Uninstall.lnk$ INSTDIR \ uninst.exe

SectionEnd



部分-Post

WriteUninstaller$ INSTDIR\uninst.exe

WriteRegStr $ {PRODUCT_UNINST_ROOT_KEY}$ {PRODUCT_UNINST_KEY} DisplayName$(^姓名)

WriteRegStr $ {PRODUCT_UNINST_ROOT_KEY}$ {PRODUCT_UNINST_KEY}UninstallString$ INSTDIR \\ uninst.exe

WriteRegStr $ {PRODUCT_UNINST_ROOT_KEY}$ {PRODUCT_UNINST_KEY}DisplayVersion$ {PRODUCT_VERSION}

WriteRegStr $ {PRODUCT_UNINST_ROOT_KEY}$ {PRODUCT_UNINST_KEY} 发布商$ {PRODUCT_PUBLISHER}

SectionEnd





功能un.onUninstSuccess

HideWindow

MessageBox MB_ICONINFORMATION | MB_OK$(^姓名)已成功从您的计算机中删除。

FunctionEnd



函数un.onInit

MessageBox MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2您确定要完全删除$(^ Name)及其所有组件吗? IDYES +2

Abort

FunctionEnd



部分卸载

删除$ INSTDIR\uninst.exe

删除$ INSTDIR \Setup1.msi



删除$ SMPROGRAMS \Shiv \ Uninstall.lnk



RMDir$ SMPROGRAMS \Shiv

RMDir$ INSTDIR



DeleteRegKey $ {PRODUCT_UNINST_ROOT_KEY}$ {PRODUCT_UNINST_KEY}

SetAutoClose true

SectionEnd



!宏SecSelect SecId

按$ 0

IntOp $ 0 $ {SF_SELECTED} | $ {SF_RO}

SectionSetFlags $ {SecId} $ 0

SectionSetInstTypes $ {SecId} 1

Pop $ 0

!macroend



!define SelectSection''!insertmacro SecSelect''

############## ###################



!macro SecUnSelect SecId

按$ 0

IntOp $ 0 $ {SF_USELECTED} | $ {SF_RO}

SectionSetFlags $ {SecId} $ 0

SectionSetText $ {SecId}

Pop $ 0

!macroend



!定义UnSelectSection''!insertmacro SecUnSelect''

############# ######################



!macro SecExtract SecId

推$ 0

IntOp $ 0 $ {SF_USELECTED} | $ {SF_RO}

SectionSetFlags $ {SecId} $ 0

SectionSetInstTypes $ {SecId} 2

Pop $ 0

!macroend



!define SetSectionExtract''!insertmacro SecExtract''

############## #####################



!macro Groups GroupId

推送$ 0

SectionGetFlags $ {GroupId} $ 0

IntOp $ 0 $ 0 | $ {SF_RO}

IntOp $ 0 $ 0 ^ $ {SF_BOLD}

IntOp $ 0 $ 0 ^ $ {SF_EXPAND}

SectionSetFlags $ {GroupId} $ 0

Pop $ 0

!macroend



!define SetSectionGroup!insertmacro Groups

####################################



!macro GroupRO GroupId

按$ 0

IntOp $ 0 $ {SF_SECGRP} | $ {SF_RO}

SectionSetFlags $ {GroupId} $ 0

Pop $ 0

!macroend



!定义MakeGroupReadOnly''!insertmacro GroupRO''



函数SetupDotNetSectionIfNeeded



StrCpy $ 0 0

StrCpy $ 1SOFTWARE\Microsoft\.NETFramework;注册表条目。

StrCpy $ 2 0



StartEnum:

;枚举已安装的版本。

EnumRegKey $ 3 HKLM$ 1 \ policy$ 2



;如果我们没有找到任何版本安装,那就不在这里。

StrCmp $ 3noDotNet notEmpty



;我们发现了一些东西。

notEmpty:

;看看RegKey是否以''v'开头。

;如果没有,请转到下一个键。

StrCpy $ 4 $ 3 1 0

StrCmp $ 4v+1 goNext

StrCpy $ 4 $ 3 1 1



;以''v'开头。现在检查一下安装好的主要版本

;是否与我们所需的主要版本有关。

;如果等于检查次要版本,如果它是'更高,

;我们找到了一个好的RegKey。

IntCmp $ 4 $ {DOT_MAJOR} +1 goNext yesDotNetReg

;检查次要版本。如果它等于或大于我们要求的

;版本则我们很好。

StrCpy $ 4 $ 3 1 3

IntCmp $ 4 $ {DOT_MINOR} yesDotNetReg goNext yesDotNetReg



goNext:

;转到下一个RegKey。

IntOp $ 2 $ 2 + 1

转到StartEnum



yesDotNetReg:

;现在我们找到了一个好的RegKey,让'确保它'实际上是

;通过获取安装路径并检查

; mscorlib.dll是否存在来安装。 $>
EnumRegValue $ 2 HKLM$ 1\policy\ $ 30

; $ 2应该等于主要和次要版本之后的任何内容

;(即,v1.1.4322)

StrCmp $ 2noDotNet

ReadRegStr $ 4 HKLM $ 1InstallRoot

;希望安装根目录不是空的。

StrCmp $ 4noDotNet

;构建mscorlib.dll的实际目录路径。

StrCpy $ 4$ 4 $ 3. $ 2 \\m scorlib.dll

IfFileExists $ 4 yesDotNet noDotNet



noDotNet:

$ {SelectSection} $ {SECDOTNET}

转到完成



yesDotNet:

;一切都结账了。继续安装的其余部分。

$ {UnSelectSection} $ {SECDOTNET}

转到完成



完成:

;全部完成。



功能结束



!define BASE_URL http://download.microsoft.com/download

; .NET Framework

;英语

!定义URL_DOTNET_1033http://download.microsoft.com/download/1/B/E/1BE39E79-7E39-46A3-96FF-047F95396215/dotNetFx40_Full_setup.exe



; ...如果您需要上面未列出的内容,则必须访问Microsoft下载站点,

;选择您所使用的语言并扫描页面来源以获取链接。





VarLANGUAGE_DLL_TITLE

VarLANGUAGE_DLL_INFO

VarURL_DOTNET

VarOSLANGUAGE

VarDOTNET_RETURN_CODE





LangString DESC_REMAINING $ {LANG_ENGLISH}(剩余%d%s%s)

LangString DESC_PROGRESS $ {LANG_ENGLISH}%d 。%01dkB / s;%dkB(%d %%)%dkB @%d。%01dkB / s

LangString DESC_PLURAL $ {LANG_ENGLISH}s

LangString DESC_HOUR $ {LANG_ENGLISH}小时

LangString DESC_MINUTE $ {LANG_ENGLISH}分钟

LangString DESC_SECOND $ {LANG_ENGLISH}second

LangString DESC_CONNECTING $ {LANG_ENGLISH}正在连接......

LangString DESC_DOWNLOADING $ {LANG_ENGLISH}正在下载%s

LangString DESC_SHORTDOTNET $ {LANG_ENGLISH} Microsoft .Net Framework 4.0

LangString DESC_LONGDOTNET $ {LANG_ENGLISH}Mi克罗夫特.Net Framework 4.0

LangString DESC_DOTNET_DECISION $ {LANG_ENGLISH}$(DESC_SHORTDOTNET)是必需的。$ \ n强烈\

建议您安装$ \\ \\ n $(DESC_SHORTDOTNET)继续之前。$ \ n如果你选择继续,\

你需要连接互联网上的$ \ n才能继续。$ \ n你想继续吗?用\

安装?

LangString SEC_DOTNET $ {LANG_ENGLISH}$(DESC_SHORTDOTNET)

LangString DESC_INSTALLING $ {LANG_ENGLISH}安装

LangString DESC_DOWNLOADING1 $ {LANG_ENGLISH}正在下载

LangString DESC_DOWNLOADFAILED $ {LANG_ENGLISH}下载失败:

LangString ERROR_DOTNET_DUPLICATE_INSTANCE $ { LANG_ENGLISH}$(DESC_SHORTDOTNET)安装程序已经运行了\



LangString ERROR_NOT_ADMINISTRATOR $ {LANG_ENGLISH}$(DESC_000022)

LangString ERROR_INVALID_PLATFORM $ {LANG_ ENGLISH}$(DESC_000023)

LangString DESC_DOTNET_TIMEOUT $ {LANG_ENGLISH}安装$(DESC_SHORTDOTNET)\

已经超时。

LangString ERROR_DOTNET_INVALID_PATH $ {LANG_ENGLISH}$(DESC_SHORTDOTNET)安装$ \ n \

在以下位置找不到:$ \ n

LangString ERROR_DOTNET_FATAL $ {LANG_ENGLISH}在$(DESC_SHORTDOTNET)安装$ \ n \\ n

期间发生了致命错误。

LangString FAILED_DOTNET_INSTALL $ { LANG_ENGLISH}$(PRODUCT_NAME)的安装将为$ \ n \

继续。但是,安装后可能无法正常运行$ \ nuntil $(DESC_SHORTDOTNET)$ \\\ n。





部分$(SEC_DOTNET )SECDOTNET

SectionIn RO

IfSilent lbl_IsSilent

!define DOTNETFILESDIRCommon \Files \ MSNET

StrCpy $ DOTNET_RETURN_CODE0

!ifdef DOTNET_ONCD_1033

StrCmp$ OSLANGUAGE10330 lbl_Not1033

SetOutPath$ PLUGINSDIR

file / r$ {DOTNETFILESDIR} \dotNetFx40_Full_x86_x64.exe

DetailPrint$(DESC_INSTALLING)$(DESC_SHORTDOTNET)...

Banner :: show / NOUNLOAD$(DESC_INSTALLING)$(DESC_SHORTDOTNET)...

nsExec :: ExecToStack''$ PLUGINSDIR \dotNetFx40_Full_x86_x64.exe/ q / c:install。 exe / noaspupgrade / q''

pop $ DOTNET_RETURN_CODE

Banner :: destroy

SetRebootFlag true

转到lbl_NoDownloadRequired

lbl_Not1033:

!endif

;我这里有其他语言版块



;以下Goto和Label是为了保持一致。

转到lbl_DownloadRequired

lbl_DownloadRequired:

DetailPrint$(DESC_DOWNLOADING1)$(DESC_SHORTDOTNET)...

MessageBox MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2$(DESC_DOTNET_DECISION)/ SD IDNO \

IDYES +2 IDNO 0

Abort

; 下载Microsoft .Net Framework

AddSize 153600

nsisdl :: download / TRANSLATE$(DESC_DOWNLOADING)$(DESC_CONNECTING)\

$(DESC_SECOND)$(DESC_MINUTE)$(DESC_HOUR)$(DESC_PLURAL)\

$(DESC_PROGRESS)$(DESC_REMAINING)\\ \\ / $
/ TIMEOUT = 30000$ URL_DOTNET$ PLUGINSDIR \dotNetFx40_Full_x86_x64.exe

Pop $ 0

StrCmp$ 0成功lbl_continue

DetailPrint$(DESC_DOWNLOADFAILED)$ 0

Abort



lbl_continue:

DetailPrint$(DESC_INSTALLING)$(DESC_SHORTDOTNET)...

Banner :: show / NOUNLOAD$(DESC_INSTALLING)$(DESC_SHORTDOTNET)...

nsExec :: ExecToStack''$ PLUGINSDIR \dotNetFx40_Full_x86_x64.exe/ q /c:\"install.exe / noaspupgrade / q''

pop $ DOTNET_RETURN_CODE

Banner :: destroy

SetRebootFlag true

;沉默编译器

转到lbl_NoDownloadRequired

lbl_NoDownloadRequired:



;获取任何错误代码并通知用户($ DOTNET_RETURN_CODE)

;如果nsExec无法执行该过程,

;它将返回错误

;如果进程超时,它将返回超时

;否则它将从执行的进程返回返回代码。

StrCmp$ DOTNET_RETURN_CODElbl_NoError

StrCmp$ DOTNET_RETURN_CODE0lbl_NoError

StrCmp$ DOTNET_RETURN_CODE3010lbl_NoError

StrCmp$ DOTNET_RETURN_CODE8192lbl_NoError

StrCmp$ DOTNET_RETURN_CODEerrorlbl_Error

StrCmp$ DOTNET_RETURN_CODEtimeoutlbl_TimeOut

;这是.Net错误

StrCmp$ DOTNET_RETURN_CODE4101lbl_Error_DuplicateInstance

StrCmp$ DOTNET_RETURN_CODE4097lbl_Error_NotAdministrator

StrCmp $ DOTNET_RETURN_CODE1633lbl_Error_InvalidPlatform lbl_FatalError

;所有其他人都是致命的



lbl_Error_DuplicateInstance:

DetailPrint$(ERROR_DOTNET_DUPLICATE_INSTANCE)

GoTo lbl_Done


lbl_Error_NotAdministrator:

DetailPrint$(ERROR_NOT_ADMINISTRATOR)

GoTo lbl_Done



lbl_Error_InvalidPlatform:

DetailPrint$(ERROR_INVALID_PLATFORM)

GoTo lbl_Done



lbl_TimeOut :

DetailPrint$(DESC_DOTNET_TIMEOUT)

GoTo lbl_Done



lbl_Error:

DetailPrint$(ERROR_DOTNET_INVALID_PATH)

GoTo lbl_Done



lbl_FatalError:

DetailPrint$(ERROR_DOTNET_FATAL )[$ DOTNET_RETURN_CODE]

GoTo lbl_Done



lbl_Done:

DetailPrint$(FAILED_DOTNET_INSTALL)< br $>
lbl_NoError:

lbl_IsSilent:

SectionEnd





===== ==============



[/已添加]

I created one set up in visual studio 2010. I want dot net framework install silently if he is not present in users machine. I created script in NSIS but I am not able to add this framework 4.0. I found so many script in google but no one make more benefit for me. Can any one tell me how to make set up with silent installation of above framework


[Added]

Can u plz tell me how and where to write a program to silently install dot net framework 4.0. I create this script using my set up but it is not working

==================================
; Usage
; 1 Call SetupDotNetSectionIfNeeded from .onInit function
; This function will check if the required version
; or higher version of the .NETFramework is installed.
; If .NET is NOT installed the section which installs dotnetfx is selected.
; If .NET is installed the section which installs dotnetfx is unselected.

#!define SF_USELECTED 0
#!define SF_SELECTED 1
#!define SF_SECGRP 2
#!define SF_BOLD 8
#!define SF_RO 16
#!define SF_EXPAND 32
###############################

!define DOT_MAJOR 4
!define DOT_MINOR 4

!define PRODUCT_NAME "Shiv"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "Idha"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\Shiv"
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "D:\SHIV\Projects\PlayGame\Setup1\Debug\Setup1.msi"
SectionEnd

Section -AdditionalIcons
CreateDirectory "$SMPROGRAMS\Shiv"
CreateShortCut "$SMPROGRAMS\Shiv\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\Setup1.msi"

Delete "$SMPROGRAMS\Shiv\Uninstall.lnk"

RMDir "$SMPROGRAMS\Shiv"
RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd

!macro SecSelect SecId
Push $0
IntOp $0 ${SF_SELECTED} | ${SF_RO}
SectionSetFlags ${SecId} $0
SectionSetInstTypes ${SecId} 1
Pop $0
!macroend

!define SelectSection ''!insertmacro SecSelect''
#################################

!macro SecUnSelect SecId
Push $0
IntOp $0 ${SF_USELECTED} | ${SF_RO}
SectionSetFlags ${SecId} $0
SectionSetText ${SecId} ""
Pop $0
!macroend

!define UnSelectSection ''!insertmacro SecUnSelect''
###################################

!macro SecExtract SecId
Push $0
IntOp $0 ${SF_USELECTED} | ${SF_RO}
SectionSetFlags ${SecId} $0
SectionSetInstTypes ${SecId} 2
Pop $0
!macroend

!define SetSectionExtract ''!insertmacro SecExtract''
###################################

!macro Groups GroupId
Push $0
SectionGetFlags ${GroupId} $0
IntOp $0 $0 | ${SF_RO}
IntOp $0 $0 ^ ${SF_BOLD}
IntOp $0 $0 ^ ${SF_EXPAND}
SectionSetFlags ${GroupId} $0
Pop $0
!macroend

!define SetSectionGroup "!insertmacro Groups"
####################################

!macro GroupRO GroupId
Push $0
IntOp $0 ${SF_SECGRP} | ${SF_RO}
SectionSetFlags ${GroupId} $0
Pop $0
!macroend

!define MakeGroupReadOnly ''!insertmacro GroupRO''

Function SetupDotNetSectionIfNeeded

StrCpy $0 "0"
StrCpy $1 "SOFTWARE\Microsoft\.NETFramework" ;registry entry to look in.
StrCpy $2 0

StartEnum:
;Enumerate the versions installed.
EnumRegKey $3 HKLM "$1\policy" $2

;If we don''t find any versions installed, it''s not here.
StrCmp $3 "" noDotNet notEmpty

;We found something.
notEmpty:
;Find out if the RegKey starts with ''v''.
;If it doesn''t, goto the next key.
StrCpy $4 $3 1 0
StrCmp $4 "v" +1 goNext
StrCpy $4 $3 1 1

;It starts with ''v''. Now check to see how the installed major version
;relates to our required major version.
;If it''s equal check the minor version, if it''s greater,
;we found a good RegKey.
IntCmp $4 ${DOT_MAJOR} +1 goNext yesDotNetReg
;Check the minor version. If it''s equal or greater to our requested
;version then we''re good.
StrCpy $4 $3 1 3
IntCmp $4 ${DOT_MINOR} yesDotNetReg goNext yesDotNetReg

goNext:
;Go to the next RegKey.
IntOp $2 $2 + 1
goto StartEnum

yesDotNetReg:
;Now that we''ve found a good RegKey, let''s make sure it''s actually
;installed by getting the install path and checking to see if the
;mscorlib.dll exists.
EnumRegValue $2 HKLM "$1\policy\$3" 0
;$2 should equal whatever comes after the major and minor versions
;(ie, v1.1.4322)
StrCmp $2 "" noDotNet
ReadRegStr $4 HKLM $1 "InstallRoot"
;Hopefully the install root isn''t empty.
StrCmp $4 "" noDotNet
;build the actuall directory path to mscorlib.dll.
StrCpy $4 "$4$3.$2\mscorlib.dll"
IfFileExists $4 yesDotNet noDotNet

noDotNet:
${SelectSection} ${SECDOTNET}
goto done

yesDotNet:
;Everything checks out. Go on with the rest of the installation.
${UnSelectSection} ${SECDOTNET}
goto done

done:
;All done.

FunctionEnd

!define BASE_URL http://download.microsoft.com/download
; .NET Framework
; English
!define URL_DOTNET_1033 "http://download.microsoft.com/download/1/B/E/1BE39E79-7E39-46A3-96FF-047F95396215/dotNetFx40_Full_setup.exe"

; ... If you need one not listed above you will have to visit the Microsoft Download site,
; select the language you are after and scan the page source to obtain the link.


Var "LANGUAGE_DLL_TITLE"
Var "LANGUAGE_DLL_INFO"
Var "URL_DOTNET"
Var "OSLANGUAGE"
Var "DOTNET_RETURN_CODE"


LangString DESC_REMAINING ${LANG_ENGLISH} " (%d %s%s remaining)"
LangString DESC_PROGRESS ${LANG_ENGLISH} "%d.%01dkB/s" ;"%dkB (%d%%) of %dkB @ %d.%01dkB/s"
LangString DESC_PLURAL ${LANG_ENGLISH} "s"
LangString DESC_HOUR ${LANG_ENGLISH} "hour"
LangString DESC_MINUTE ${LANG_ENGLISH} "minute"
LangString DESC_SECOND ${LANG_ENGLISH} "second"
LangString DESC_CONNECTING ${LANG_ENGLISH} "Connecting..."
LangString DESC_DOWNLOADING ${LANG_ENGLISH} "Downloading %s"
LangString DESC_SHORTDOTNET ${LANG_ENGLISH} "Microsoft .Net Framework 4.0"
LangString DESC_LONGDOTNET ${LANG_ENGLISH} "Microsoft .Net Framework 4.0"
LangString DESC_DOTNET_DECISION ${LANG_ENGLISH} "$(DESC_SHORTDOTNET) is required.$\nIt is strongly \
advised that you install$\n$(DESC_SHORTDOTNET) before continuing.$\nIf you choose to continue, \
you will need to connect$\nto the internet before proceeding.$\nWould you like to continue with \
the installation?"
LangString SEC_DOTNET ${LANG_ENGLISH} "$(DESC_SHORTDOTNET) "
LangString DESC_INSTALLING ${LANG_ENGLISH} "Installing"
LangString DESC_DOWNLOADING1 ${LANG_ENGLISH} "Downloading"
LangString DESC_DOWNLOADFAILED ${LANG_ENGLISH} "Download Failed:"
LangString ERROR_DOTNET_DUPLICATE_INSTANCE ${LANG_ENGLISH} "The $(DESC_SHORTDOTNET) Installer is \
already running."
LangString ERROR_NOT_ADMINISTRATOR ${LANG_ENGLISH} "$(DESC_000022)"
LangString ERROR_INVALID_PLATFORM ${LANG_ENGLISH} "$(DESC_000023)"
LangString DESC_DOTNET_TIMEOUT ${LANG_ENGLISH} "The installation of the $(DESC_SHORTDOTNET) \
has timed out."
LangString ERROR_DOTNET_INVALID_PATH ${LANG_ENGLISH} "The $(DESC_SHORTDOTNET) Installation$\n\
was not found in the following location:$\n"
LangString ERROR_DOTNET_FATAL ${LANG_ENGLISH} "A fatal error occurred during the installation$\n\
of the $(DESC_SHORTDOTNET)."
LangString FAILED_DOTNET_INSTALL ${LANG_ENGLISH} "The installation of $(PRODUCT_NAME) will$\n\
continue. However, it may not function properly$\nuntil $(DESC_SHORTDOTNET)$\nis installed."


Section $(SEC_DOTNET) SECDOTNET
SectionIn RO
IfSilent lbl_IsSilent
!define DOTNETFILESDIR "Common\Files\MSNET"
StrCpy $DOTNET_RETURN_CODE "0"
!ifdef DOTNET_ONCD_1033
StrCmp "$OSLANGUAGE" "1033" 0 lbl_Not1033
SetOutPath "$PLUGINSDIR"
file /r "${DOTNETFILESDIR}\dotNetFx40_Full_x86_x64.exe"
DetailPrint "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..."
Banner::show /NOUNLOAD "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..."
nsExec::ExecToStack ''"$PLUGINSDIR\dotNetFx40_Full_x86_x64.exe" /q /c:"install.exe /noaspupgrade /q"''
pop $DOTNET_RETURN_CODE
Banner::destroy
SetRebootFlag true
Goto lbl_NoDownloadRequired
lbl_Not1033:
!endif
; Insert Other language blocks here

; the following Goto and Label is for consistency.
Goto lbl_DownloadRequired
lbl_DownloadRequired:
DetailPrint "$(DESC_DOWNLOADING1) $(DESC_SHORTDOTNET)..."
MessageBox MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 "$(DESC_DOTNET_DECISION)" /SD IDNO \
IDYES +2 IDNO 0
Abort
; "Downloading Microsoft .Net Framework"
AddSize 153600
nsisdl::download /TRANSLATE "$(DESC_DOWNLOADING)" "$(DESC_CONNECTING)" \
"$(DESC_SECOND)" "$(DESC_MINUTE)" "$(DESC_HOUR)" "$(DESC_PLURAL)" \
"$(DESC_PROGRESS)" "$(DESC_REMAINING)" \
/TIMEOUT=30000 "$URL_DOTNET" "$PLUGINSDIR\dotNetFx40_Full_x86_x64.exe"
Pop $0
StrCmp "$0" "success" lbl_continue
DetailPrint "$(DESC_DOWNLOADFAILED) $0"
Abort

lbl_continue:
DetailPrint "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..."
Banner::show /NOUNLOAD "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..."
nsExec::ExecToStack ''"$PLUGINSDIR\dotNetFx40_Full_x86_x64.exe" /q /c:"install.exe /noaspupgrade /q"''
pop $DOTNET_RETURN_CODE
Banner::destroy
SetRebootFlag true
; silence the compiler
Goto lbl_NoDownloadRequired
lbl_NoDownloadRequired:

; obtain any error code and inform the user ($DOTNET_RETURN_CODE)
; If nsExec is unable to execute the process,
; it will return "error"
; If the process timed out it will return "timeout"
; else it will return the return code from the executed process.
StrCmp "$DOTNET_RETURN_CODE" "" lbl_NoError
StrCmp "$DOTNET_RETURN_CODE" "0" lbl_NoError
StrCmp "$DOTNET_RETURN_CODE" "3010" lbl_NoError
StrCmp "$DOTNET_RETURN_CODE" "8192" lbl_NoError
StrCmp "$DOTNET_RETURN_CODE" "error" lbl_Error
StrCmp "$DOTNET_RETURN_CODE" "timeout" lbl_TimeOut
; It''s a .Net Error
StrCmp "$DOTNET_RETURN_CODE" "4101" lbl_Error_DuplicateInstance
StrCmp "$DOTNET_RETURN_CODE" "4097" lbl_Error_NotAdministrator
StrCmp "$DOTNET_RETURN_CODE" "1633" lbl_Error_InvalidPlatform lbl_FatalError
; all others are fatal

lbl_Error_DuplicateInstance:
DetailPrint "$(ERROR_DOTNET_DUPLICATE_INSTANCE)"
GoTo lbl_Done

lbl_Error_NotAdministrator:
DetailPrint "$(ERROR_NOT_ADMINISTRATOR)"
GoTo lbl_Done

lbl_Error_InvalidPlatform:
DetailPrint "$(ERROR_INVALID_PLATFORM)"
GoTo lbl_Done

lbl_TimeOut:
DetailPrint "$(DESC_DOTNET_TIMEOUT)"
GoTo lbl_Done

lbl_Error:
DetailPrint "$(ERROR_DOTNET_INVALID_PATH)"
GoTo lbl_Done

lbl_FatalError:
DetailPrint "$(ERROR_DOTNET_FATAL)[$DOTNET_RETURN_CODE]"
GoTo lbl_Done

lbl_Done:
DetailPrint "$(FAILED_DOTNET_INSTALL)"
lbl_NoError:
lbl_IsSilent:
SectionEnd


===================

[/Added]

推荐答案

{PRODUCT_NAME}

!定义PRODUCT_UNINST_ROOT_KEYHKLM



; MUI 1.67兼容------

!包括MUI.nsh



; MUI设置

!定义MUI_ABORTWARNING

!定义MUI_ICON
{PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "


{NSISDIR} \ Contrib\Graphics \ Icons \ modern-install.ico

!define MUI_UNICON
{NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "


{NSISDIR} \Contrib\Graphics\Icons\modern-uninstall.ico< br $> b $ b

;欢迎页面

!insertmacro MUI_PAGE_WELCOME

;目录页

!insertmacro MUI_PAGE_DIRECTORY

; Instfiles页面

!insertmacro MUI_PAGE_INSTFILES

;完成页面

!insertmacro MUI_PAGE_FINISH



;卸载程序页面

!insertmacro MUI_UNPAGE_INSTFILES



;语言文件

!insertmacro MUI_LANGUAGE英语



; MUI结束------



名称
{NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "


这篇关于如何静默安装dot net framework 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆