我从.Net 7机器上学到的是,当我安装WindowsFramework4.7.1时,它需要重新启动才能生效,否则使用此windows版本设计的应用程序将无法启动。
那么,如果我在.Net服务器版本(2008r2以上)上安装Windows 4.7.1,我也需要重新启动吗?
我想通过一个脚本自动安装.Net fx和应用程序这一块,所以我已经实现了脚本块,但不确定重启windows服务器
如果我确实想重启windows服务器,那么这可以作为我的power shell脚本的一部分来添加吗?
编辑我的示例脚本如下所示
if(Test-Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'){
$NetRegKey = Get-Childitem %%'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
if($NetRegKey){
$Release = $NetRegKey.GetValue("Release")
if($Release){
if($Release -lt 461308){
try{
$prc = Start-Process C:\NDP471-KB4033342-x86-x64-AllOS-ENU.exe -Wait
}
catch{
}
}
}
}
}
else{
try{
$prc = Start-Process C:\NDP471-KB4033342-x86-x64-AllOS-ENU.exe -Wait
}
catch{
}
}
发布于 2019-07-24 21:44:46
我在上面的问题中找到了解决方案
if( -NOT ((Test-Path 'HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.7.1') -or (Test-Path 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe') -or (Test-Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'))) {
Start-Process .\DotNetFX471\NDP471-KB4033342-x86-x64-AllOS-ENU.exe -RedirectStandardError "DotNetInstallationStatus.txt" -Wait
if ($LastExitCode -ne 0){
Write-Host "ERROR: "
Get-Content -Path .\appInstallStatus.txt
return
}
Write-Host ".Net Framework installation is completed successfully"
}
Write-Host "Running CIE installer, please wait..."
$installerParam = "--p 'C:\Program Files\APP'"
Start-Process .\install.exe $installerParam -RedirectStandardError "appInstallStatus.txt" -Wait
if ($LastExitCode -ne 0){
Write-Host "ERROR: "
Get-Content -Path .\appInstallStatus.txt
return
}
一旦我们在任何windows服务器上安装了.Net框架,我们应该会看到在"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe“上创建的文件夹,运行这个MSBuild.exe来获取版本。通常情况下,如果我们没有.Net框架,那么这个文件夹将不可用,但是如果这个文件夹可用,那么您可以通过运行这个MSBuild.exe文件来获得正确的.Net框架版本。
https://stackoverflow.com/questions/57110675
复制相似问题