注:本文为作者原创文章,转载于引用请注明出处,谢谢。

今天在x64的英文版Windows Server 2012 r2上安装最新版的 Visual Studio 2015 Exterprise 时,提示需要重新启动:

于是我restart了N次,可还是不行,在网上进行搜索,发现能在日志文件中找到原因,日志文件在C:\Users\%username%\AppData\Local\Temp中,或者直接在安装界面点“日志文件”进入。

参考日志文件的Condition(环境检查)部分:

   [0A60:][--10T18::]i000: MUX:  Failed to download the update xml file from http://go.microsoft.com/fwlink/?LinkID=500683 Setup will not be updated.
[0A60:][--10T18::]i052: Condition '(VersionNT = v6.3) AND (WindowsBuildNumber < 9600)' evaluates to false.
[0A60:][--10T18::]i052: Condition 'CompatibilityMode = 0' evaluates to false.
[0A60:][--10T18::]i052: Condition 'NOT((VersionNT > v6.1) OR (VersionNT = v6.1 AND ServicePackLevel >= 1))' evaluates to false.
[0A60:][--10T18::]i052: Condition '(NOT IsLanguagePack) AND ( CurrentOperation = "Install" ) AND ( FLP_Version > v14.0.22823 )' evaluates to false.
[0A60:][--10T18::]i052: Condition 'RebootPending = 1' evaluates to true.
[0A60:][--10T18::]i052: Condition 'NOT (IEsvcVersionExists) OR (IEsvcVersion < v10.0)' evaluates to false.
[0A60:][--10T18::]i052: Condition '(VersionNT < v6.2) AND ((NetworkAvailable = 0) OR (DisableRootAutoUpdate = 1)) AND NOT ((MicrosoftRootCertificateAuthority2011RootExists OR MicrosoftRootCertificateAuthority2011AuthRootExists) AND (MicrosoftRootCertificateAuthority2010RootExists OR MicrosoftRootCertificateAuthority2010AuthRootExists))' evaluates to false.
[0A60:][--10T18::]i052: Condition '( CurrentOperation = "Install" AND EnterpriseExists )' evaluates to false.
[0A60:][--10T18::]i052: Condition '( CurrentOperation = "Install" AND UltimateExists )' evaluates to false.
[0A60:][--10T18::]i052: Condition '( CurrentOperation = "Install" AND NOT EnterpriseExists AND ProfessionalExists)' evaluates to false.
[0A60:][--10T18::]i052: Condition '(VersionNT = v6.3) AND (KB2919355_amd64_CurrentState <> 112 AND KB2919355_x86_CurrentState <> 112)' evaluates to false.
[0A60:][--10T18::]i052: Condition '(VersionNT = v6.3) AND (netfxfullredist_43_DetectKey < v4.5.22816)' evaluates to false.

发现当VS进行安装前的环境检查时,当结果为 false 时代表检查通过,结果为 true 时代表没有通过安装环境检查。

日志中显示没有通过检查的有:

[0A60:][--10T18::]i052: Condition 'RebootPending = 1' evaluates to true.

这个'RebootPending = 1'代表系统需要重启,可问题是:我重启了之后RebootPending还是等于1,这就是问题之所在

于是,在网上寻找各种关于'RebootPending = 1'的解决方案,归结于以下几种:

  1. 重启直接选择 restart 而不是 shut down 再开机。
  2. 关闭系统的休眠功能:管理员模式运行命令行,输入powercfg.exe /hibernate off 进行关闭休眠。关闭休眠后等于关闭了 win8 及以上系统的快速启动功能,这样能使得系统能真正地重启,而不是休眠之后快速启动。
  3. 在注册表中将键值HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\UpdateExeVolatile 设为0;将键 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations 删除。

在尝试以上方法之后,有可能解决一部分人的问题,可偏偏我就是另外一部分,特别是连键值HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\UpdateExeVolatile 都找不到。

网上能找的都找了,花了好几个小时,没办法,只能换一种思路:


 新思路:既然你要检查系统是否需要重新启动,那我是否能伪造一种不需要重新启动的状态给你看?

于是寻找目前检查系统重启状态的方法,发现如下方案:

https://blogs.technet.microsoft.com/heyscriptingguy/2014/10/15/use-powershell-dsc-to-check-pending-reboot/

以及它的参考:

https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542

其中使用的是 Windows power shell 对注册表进行读取、判断,从而确定 RebootPending 的值。代码如下:

Function Get-PendingReboot
{
<#
.SYNOPSIS
Gets the pending reboot status on a local or remote computer. .DESCRIPTION
This function will query the registry on a local or remote computer and determine if the
system is pending a reboot, from either Microsoft Patching or a Software Installation.
For Windows 2008+ the function will query the CBS registry key as another factor in determining
pending reboot state. "PendingFileRenameOperations" and "Auto Update\RebootRequired" are observed
as being consistant across Windows Server 2003 & 2008. CBServicing = Component Based Servicing (Windows 2008)
WindowsUpdate = Windows Update / Auto Update (Windows 2003 / 2008)
CCMClientSDK = SCCM 2012 Clients only (DetermineIfRebootPending method) otherwise $null value
PendFileRename = PendingFileRenameOperations (Windows 2003 / 2008) .PARAMETER ComputerName
A single Computer or an array of computer names. The default is localhost ($env:COMPUTERNAME). .PARAMETER ErrorLog
A single path to send error data to a log file. .EXAMPLE
PS C:\> Get-PendingReboot -ComputerName (Get-Content C:\ServerList.txt) | Format-Table -AutoSize Computer CBServicing WindowsUpdate CCMClientSDK PendFileRename PendFileRenVal RebootPending
-------- ----------- ------------- ------------ -------------- -------------- -------------
DC01 False False False False
DC02 False False False False
FS01 False False False False This example will capture the contents of C:\ServerList.txt and query the pending reboot
information from the systems contained in the file and display the output in a table. The
null values are by design, since these systems do not have the SCCM 2012 client installed,
nor was the PendingFileRenameOperations value populated. .EXAMPLE
PS C:\> Get-PendingReboot Computer : WKS01
CBServicing : False
WindowsUpdate : True
CCMClient : False
PendComputerRename : False
PendFileRename : False
PendFileRenVal :
RebootPending : True This example will query the local machine for pending reboot information. .EXAMPLE
PS C:\> $Servers = Get-Content C:\Servers.txt
PS C:\> Get-PendingReboot -Computer $Servers | Export-Csv C:\PendingRebootReport.csv -NoTypeInformation This example will create a report that contains pending reboot information. .LINK
Component-Based Servicing:
http://technet.microsoft.com/en-us/library/cc756291(v=WS.10).aspx PendingFileRename/Auto Update:
http://support.microsoft.com/kb/2723674
http://technet.microsoft.com/en-us/library/cc960241.aspx
http://blogs.msdn.com/b/hansr/archive/2006/02/17/patchreboot.aspx SCCM 2012/CCM_ClientSDK:
http://msdn.microsoft.com/en-us/library/jj902723.aspx .NOTES
Author: Brian Wilhite
Email: bcwilhite (at) live.com
Date: 29AUG2012
PSVer: 2.0/3.0/4.0/5.0
Updated: 01DEC2014
UpdNote: Added CCMClient property - Used with SCCM 2012 Clients only
Added ValueFromPipelineByPropertyName=$true to the ComputerName Parameter
Removed $Data variable from the PSObject - it is not needed
Bug with the way CCMClientSDK returned null value if it was false
Removed unneeded variables
Added PendFileRenVal - Contents of the PendingFileRenameOperations Reg Entry
Removed .Net Registry connection, replaced with WMI StdRegProv
Added ComputerPendingRename
#> [CmdletBinding()]
param(
[Parameter(Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Alias("CN","Computer")]
[String[]]$ComputerName="$env:COMPUTERNAME",
[String]$ErrorLog
) Begin { }## End Begin Script Block
Process {
Foreach ($Computer in $ComputerName) {
Try {
## Setting pending values to false to cut down on the number of else statements
$CompPendRen,$PendFileRename,$Pending,$SCCM = $false,$false,$false,$false ## Setting CBSRebootPend to null since not all versions of Windows has this value
$CBSRebootPend = $null ## Querying WMI for build version
$WMI_OS = Get-WmiObject -Class Win32_OperatingSystem -Property BuildNumber, CSName -ComputerName $Computer -ErrorAction Stop ## Making registry connection to the local/remote computer
$HKLM = [UInt32] "0x80000002"
$WMI_Reg = [WMIClass] "\\$Computer\root\default:StdRegProv" ## If Vista/2008 & Above query the CBS Reg Key
If ([Int32]$WMI_OS.BuildNumber -ge 6001) {
$RegSubKeysCBS = $WMI_Reg.EnumKey($HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\")
$CBSRebootPend = $RegSubKeysCBS.sNames -contains "RebootPending"
} ## Query WUAU from the registry
$RegWUAURebootReq = $WMI_Reg.EnumKey($HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")
$WUAURebootReq = $RegWUAURebootReq.sNames -contains "RebootRequired" ## Query PendingFileRenameOperations from the registry
$RegSubKeySM = $WMI_Reg.GetMultiStringValue($HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\","PendingFileRenameOperations")
$RegValuePFRO = $RegSubKeySM.sValue ## Query ComputerName and ActiveComputerName from the registry
$ActCompNm = $WMI_Reg.GetStringValue($HKLM,"SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\","ComputerName")
$CompNm = $WMI_Reg.GetStringValue($HKLM,"SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\","ComputerName")
If ($ActCompNm -ne $CompNm) {
$CompPendRen = $true
} ## If PendingFileRenameOperations has a value set $RegValuePFRO variable to $true
If ($RegValuePFRO) {
$PendFileRename = $true
} ## Determine SCCM 2012 Client Reboot Pending Status
## To avoid nested 'if' statements and unneeded WMI calls to determine if the CCM_ClientUtilities class exist, setting EA = 0
$CCMClientSDK = $null
$CCMSplat = @{
NameSpace='ROOT\ccm\ClientSDK'
Class='CCM_ClientUtilities'
Name='DetermineIfRebootPending'
ComputerName=$Computer
ErrorAction='Stop'
}
## Try CCMClientSDK
Try {
$CCMClientSDK = Invoke-WmiMethod @CCMSplat
} Catch [System.UnauthorizedAccessException] {
$CcmStatus = Get-Service -Name CcmExec -ComputerName $Computer -ErrorAction SilentlyContinue
If ($CcmStatus.Status -ne 'Running') {
Write-Warning "$Computer`: Error - CcmExec service is not running."
$CCMClientSDK = $null
}
} Catch {
$CCMClientSDK = $null
} If ($CCMClientSDK) {
If ($CCMClientSDK.ReturnValue -ne 0) {
Write-Warning "Error: DetermineIfRebootPending returned error code $($CCMClientSDK.ReturnValue)"
}
If ($CCMClientSDK.IsHardRebootPending -or $CCMClientSDK.RebootPending) {
$SCCM = $true
}
} Else {
$SCCM = $null
} ## Creating Custom PSObject and Select-Object Splat
$SelectSplat = @{
Property=(
'Computer',
'CBServicing',
'WindowsUpdate',
'CCMClientSDK',
'PendComputerRename',
'PendFileRename',
'PendFileRenVal',
'RebootPending'
)}
New-Object -TypeName PSObject -Property @{
Computer=$WMI_OS.CSName
CBServicing=$CBSRebootPend
WindowsUpdate=$WUAURebootReq
CCMClientSDK=$SCCM
PendComputerRename=$CompPendRen
PendFileRename=$PendFileRename
PendFileRenVal=$RegValuePFRO
RebootPending=($CompPendRen -or $CBSRebootPend -or $WUAURebootReq -or $SCCM -or $PendFileRename)
} | Select-Object @SelectSplat } Catch {
Write-Warning "$Computer`: $_"
## If $ErrorLog, log the file to a user specified location/path
If ($ErrorLog) {
Out-File -InputObject "$Computer`,$_" -FilePath $ErrorLog -Append
}
}
}## End Foreach ($Computer in $ComputerName)
}## End Process End { }## End End }## End Function Get-PendingReboot

发现其对一下几个主键进行读取:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName 

于是我开始寻找这些主键:

  • 第一个没找到,尝试删除之下的 SessionsPending ,被拒绝;
  • 找到了第二个对应的 RebootRequired ,里头有东西,备份后删除之;
  • 找到第三个对应的 PendingFileRenameOperations ,同样删除之;

没有重启的情况下尝试重新安装,成功进入安装环节!

吁~忙了一下午,终于搞定!

此时联想到之前装完系统更新时提示要重启,可后来重启过后还是要求重启,当时也没注意,没想到又给碰上了,真是缘分!

到此为止,事情可远远没有结束,明天用VS调试CEC2014程序导致MATLAB调用func19~30崩溃的问题,估计又得一整天了……还有POWELL法和DE的结合测试,想着就头皮发麻……自己选的路,喊着泪也得走下去哇

最后,原此篇文章能帮到更多的人!

解决Win8.1 / Win Server 2012 r2 下安装 Visual Studio 时一直要求重新启动的问题(原创)的更多相关文章

  1. Windows server 2012 R2下安装sharepoint2013

    • 安装windows server 2012 R2 系统,配置IP.系统打补丁,修改主机名.加域后重启.• 安装WEB服务器,勾选windows身份验证 • 安装应用程序服务器 • 安装.NET F ...

  2. Server 2012 R2 Standard 安装运行PCS7时出现“无法启动此程序,因为计算机中丢失api-ms-win-crt-runtime-l1-1-0.dll”解决方法

    网上看到了这篇文章https://www.jianshu.com/p/21f4bb8b5502,根据思路自己尝试,解决了丢失的问题.提示[计算机中丢失api-ms-win-crt-runtime-l1 ...

  3. loadrunner 联机跑负载 win server 2012 r2环境部署

    下列为在实际loadrunner 联机跑负载 win server 2012 r2环境部署中进行的成功案例,遇到的问题和解决方法,仅作整理和记录,如转载请署名及原文地址. ps:欢迎加q群872584 ...

  4. win server 2012 R2 你需要先安装 对应于 KB2919355 的更新

    产生阻滞的问题: 你需要先安装 对应于 KB2919355 的更新 ,然后才可在 Windows 8.1 或 Windows Server 2012 R2 上安装此产品. 官方说法(这些 KB 必须按 ...

  5. Windows Server 2012 R2在线安装.NET Framework3.5

    Windows Server 2012 (R2) 默认没有安装 .NET Framework 3.5,但可以通过在线安装或指定备用源路径方式. 之前在这个 在Win Server 2012中安装.NE ...

  6. 【转】Windows Server 2008 R2下安装 .net framework3.5

    原文地址:http://hi.baidu.com/tonny_dxf/item/6831bcdc3d7c06e7b2f7777c      [你必须用角色管理工具安装.net framework3.5 ...

  7. Windows Server 2012 R2上安装.Net4.6.1出错

    在Windows Server 2012 R2上安装.Net4.6.1时提示“你需要先安装对应于 KB2919355 的更新,然后才可在……”解决方式: 在官网下载更新包,下载地址:https://w ...

  8. windows 2012 r2下安装sharepoint 2013错误解决

    日前,我在安装sharepoint 2013时,需要预部署一些软件,我们知道运行产品准备工具“prerequisiteinstaller”后就可以自动下载安装配置这些软件,但是使用系统为windows ...

  9. C# 获取并判断操作系统版本,解决Win10、 Windows Server 2012 R2 读取失败的方案

    Windows 8.1, Win10之后,通过GetVersion and GetVersionEx 方法获取WIndows操作系统版本号的功能需要添加manifest文件后才能查找到,不然的话会查找 ...

随机推荐

  1. 分布式 ES 操作流程解析

    概念解析 CURD 操作 CURD 操作都是针对具体的某个或某些文档的操作,每个文档的 routing 都是确认的,所以其所在分片也是可以事先确定的.该过程对应 ES 的 Document API. ...

  2. 介绍一些适用于 Web 开发者的 Atom 编辑器插件

    Atom 的社区很繁荣,有着丰富的扩展/插件(packages).安装 Atom 的 Package 非常简单,可以在编辑器的偏好设置里面安装,也可以在命令行中使用 apm 命令来安装. 在介绍适用于 ...

  3. 排序并获取index的顺序

    //排序并获取index的顺序:4,7,2,9-->9,7,4,2-->4,2,1,3 Array.prototype.getIndex=function(){ var orderLeng ...

  4. nodejs中npm工具自身升级

    npm官方地址:https://www.npmjs.com/ npm在github上的地址:https://github.com/npm/npm 目前(截止2016-03-15)npm最新版本为3.8 ...

  5. ubuntu下使用quick2wire控制RespberryPi2的I2C

    首先,开启树莓派的I2C驱动: 查看I2C驱动是否已经被加载:ls /dev -l | grep i2c,如果有形如 i2c-x 的显示结果表明驱动已经加载,否则驱动没有加载,需要进行如下操作: 修改 ...

  6. Gvim使用心得--设置篇[转]

    1.设置自己喜欢的字体? 点“编辑”--“选择字体”, 然后在字体列表中选择一个你喜欢的字体和字号,然后确认. 如果想每次都使用这个这个字体 需要加到启动文件中 比如我的 set guifont=Co ...

  7. android之模拟器访问外网设置

    一.确定adb可用 1.1 确认adb环境变量 1.2 命令行cmd 执行adb shell启动模拟器的命令行 二.DNS确认 2.1 确定DNS是否为电脑的DNS 2.2 修改DNS地址 三.效果图

  8. Java内存溢出的详细解决方案

    本文介绍了Java内存溢出的详细解决方案.本文总结内存溢出主要有两种情况,而JVM经常调用垃圾回收器解决内存堆不足的问题,但是有时仍会有内存不足的错误.作者分析了JVM内存区域组成及JVM设置虚拟内存 ...

  9. 12天学好C语言——记录我的C语言学习之路(Day 12)

    12天学好C语言--记录我的C语言学习之路 Day 12: 进入最后一天的学习,用这样一个程序来综合考量指针和字符串的关系,写完这个程序,你对字符串和指针的理解应该就不错了. //输入一个字符串,内有 ...

  10. jQuery 源码分析4: jQuery.extend

    jQuery.extend是jQuery最重要的方法之一,下面看看jQuery是怎样实现扩展操作的 // 如果传入一个对象,这个对象的属性会被添加到jQuery对象中 // 如果传入两个或多个对象,所 ...