今天遇到一个客户在安装 . NET Framework 4.5.2的时候遇到了这样的报错:“Final Result: Installation failed with error code: (0x80070660), "The Temp folder is on a drive that is full or is inaccessible. Free up space on the drive or verify that you have write permission on the Temp folder. " (Elapsed time: 0 00:01:04).””
从错误信息上看,似乎是因为temp文件夹没有权限访问或是磁盘空间不够了,于是清理磁盘空间,用disk cleanup tool清理temp文件,并且尝试了在%temp%以及“%windir%”\temp文件夹中删除文件,发现都具有权限。
可是再次安装 .NET Framework 4.5.2依然失败,还是报这样的错。然后检查了VS log 发现了如下的错误
MSI (s) (38:B8) [13:27:35:229]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (38:B8) [13:27:35:229]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (38:B8) [13:27:35:230]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\InProgress 3: 2
MSI (s) (38:B8) [13:27:35:230]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\InProgress 3: 2
MSI (s) (38:B8) [13:27:35:230]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (s) (38:B8) [13:27:35:230]: Restoring environment variables
MSI (c) (DC:54) [13:27:35:235]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (DC:54) [13:27:35:235]: MainEngineThread is returning 1632
查询了错误代码1632,发现依然指向“The Temp folder is on a drive that is full or is inaccessible. ”
经过网上查询,发现其实除了 .NET Framework之外,还有其他的app安装时候也会遇到这个问题,可见这并不是一个 .NET 安装的问题, 而是系统的问题。原来在系统盘中有一个c:\windows\installer文件夹,这是windows installer的文件夹,里面有安装msi文件所需的缓存文件。这个文件夹非常重要,处于系统保护和隐藏之下,轻易不应该去修改这个文件夹。
同时这个文件夹比较大,有些人为了节约系统盘的空间,有时会将这个文件夹移到别处并进行redirect操作。(具体细节请百度)于是查询客户的机器上,果然这个文件夹被移走了,只剩下一个shortcut快捷方式。于是删除这个快捷方式,并且重建了一个c:\windows\Installer的文件夹,然后 .NET Framework就可以顺利安装了。