天天看點

使用腳本巧解office安裝源問題(修正版)

最近由于由于給用戶端下派office更新檔導緻大量客戶計算機office元件無法正常使用,彈出某個檔案定位的一個提示視窗,造成該問題的主要原因是由于office後續的核心元件或者關鍵元件更新時需要使用到源安裝路徑或者源安裝CD光牒或者源安裝緩存(MSOcache)。如果源路徑不存在或者緩存丢失,就造成上述現象。

如何避免上述問題或者發生之後如何解決?

1.安裝完office後,再最後完成的那一頁不要選擇删除“安裝緩存”,安裝緩存會存放在剩餘空間最大的分區中,命名為MSOcache(隐藏檔案)。如果儲存了安裝緩存将不會造成上述問題。

2.如果公司的用戶端全部是做的ghost鏡像并且沒有保留緩存,那就隻有使用組政策下派腳本來批量解決問題了。

解決思路:修改系統資料庫中的office緩存檔案定位路徑。

office系統資料庫路徑:

HKEY_CLASSES_ROOT\Installer\Products\*

其中*為一個字元串值,例如

4080110900063D11C8EF10054038389C或9040110900063D11C8EF10054038389C

複制以下代碼為OfficeSource.vbs,然後通過組政策下發。

On Error Resume Next  

Const HKEY_CLASSES_ROOT = &H80000000  

strComputer = "." 

strFilePath = "\\Filesrv\Software\Office\"  '定義office網絡安裝路徑  

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")  

strKeyPath = "Installer\Products" 

oReg.EnumKey HKEY_CLASSES_ROOT, strKeyPath, arrStrings  

'從系統資料庫strKeyPath鍵值下查詢産品Microsoft Office 2000 SR-1 Professional和Microsoft Office Professional Edition 2003并定位安裝路徑  

For i=0 To UBound(arrStrings)  

strValueName = "ProductName" 

strkeypath1 = "Installer\Products\" & arrStrings(i)  

oReg.GetStringValue HKEY_CLASSES_ROOT, strkeypath1, strValueName, strValue1  

If InStr(strValue1, "Microsoft Office 2000 SR-1 Professional") Then  

strkeypath2 = strKeyPath1 

strOffVer = "Office2000\" 

strFullPath = strFilePath & strOffVer  

strfile = "DATA1.MSI" 

End If  

If InStr(strValue1, "Microsoft Office Professional Edition 2003") Then  

strOffVer = "Office2003\" 

strfile = "PRO11.MSI" 

Next  

'根據不同語言定位安裝路徑,隻包含簡、繁、英、日四種。  

strKeyPath3 = strKeyPath2 

strValueName3 = "Language" 

oReg.GetDWORDValue HKEY_CLASSES_ROOT,strKeyPath3,strValueName3,dwValue3  

If dwValue3 = "2052" Then  

 strLang = "CN\" 

 strKeyPath4 = strKeyPath3 & "\" & "SourceList"  

 strValueName4 = "LastUsedSource" 

 strValue4 = "n;1;" & strFullPath & strLang  

 oReg.SetExpandedStringValue HKEY_CLASSES_ROOT,strKeyPath4,strValueName4,strValue4  

 strKeyPath5 = strKeyPath3 & "\" & "SourceList"  

 strValueName5 = "PackageName" 

 strValue5 = strfile 

 oReg.SetStringValue HKEY_CLASSES_ROOT,strKeyPath5,strValueName5,strValue5  

 strKeyPath6 = strKeyPath3 & "\" & "SourceList"  & "\" & "Net"  

 strValueName6 = "1" 

 strValue6 = strFullPath & strLang  

 oReg.SetExpandedStringValue HKEY_CLASSES_ROOT,strKeyPath6,strValueName6,strValue6  

Elseif dwValue3 = "1028" Then  

 strLang = "TC\" 

Elseif dwValue3 = "1041" Then  

 strLang = "JP\" 

Elseif dwValue3 = "1033" Then  

 strLang = "EN\" 

End If 

本文轉自yangye1985 51CTO部落格,原文連結:http://blog.51cto.com/yangye/295811,如需轉載請自行聯系原作者

繼續閱讀