Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\./root/default:StdRegProv")
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objNetwork : set objNetwork = CreateObject("Wscript.Network")
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
Dim strProfilePath, strOS, strVerKey, strVersion, strProgFilesDir,strRegFilePath2003,strRegFilePath2007,strRegFilePath2010, strProgramPath
Dim sValuneName, SRegPre, SRegPost
objShell.Run "taskkill /IM winword.exe",1,true
strOS = objShell.ExpandEnvironmentStrings("%OS%")
If strOS = "Windows_NT" Then
strVerKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
strVersion = objShell.regread(strVerKey & "ProductName")
Else
strVerKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\"
strVersion = objShell.regread(strVerKey & "ProductName")
End If
If strVersion = "Windows 7 Professional" Then
strProfilePath = objShell.ExpandEnvironmentStrings("%UserProfile%")_
& "\AppData\Roaming\Microsoft\Templates"
If Not objFSO.FolderExists(strProfilePath) Then
Set objFolder = objFSO.CreateFolder(strProfilePath)
End If
ElseIf strVersion = "Microsoft Windows XP" Then
strProfilePath = objShell.ExpandEnvironmentStrings("%UserProfile%")_
& "\Application Data\Microsoft\Templates"
If Not objFSO.FolderExists(strProfilePath) Then
Set objFolder = objFSO.CreateFolder(strProfilePath)
End If
End If
sValueName = "Path"
sRegPre = "SOFTWARE\Microsoft\Office\"
sRegPost = "\Common\InstallRoot"
If oReg.GetStringValue( _
HKLM, sRegPre & "14.0" & sRegPost, sValueName, sValue) = 0 Then
'###################### START OF 2010 #####################
If objFSO.FileExists (strProfilePath & "normal.dotm") Then
If objFSO.FolderExists(strProfilePath & "\old-normal") = False Then
objFSO.CreateFolder strProfilePath & "\old-normal"
End If
objFSO.CopyFile strProfilePath & "\normal.dotm", strProfilePath & "\old-normal\"
End If
objFSO.CopyFile "\\domain.local\share\Logon\Font\Office2007-10\Normal.dotm", strProfilePath & "\", True
strRegFilePath2010 = "\\domain.local\share\Logon\Font\Office2007-10\Outlook2010.reg"
objShell.Run "regedit /s """ & strRegFilePath2010 & """"
'####################### END OF 2010 ######################
Elseif oReg.GetStringValue( _
HKLM, sRegPre & "12.0" & sRegPost, sValueName, sValue) = 0 Then
'###################### START OF 2007 #####################
If objFSO.FileExists (strProfilePath & "normal.dotm") Then
If objFSO.FolderExists(strProfilePath & "\old-normal") = False Then
objFSO.CreateFolder strProfilePath & "\old-normal"
End If
objFSO.CopyFile strProfilePath & "\normal.dotm", strProfilePath & "\old-normal\"
End If
objFSO.CopyFile "\\domain.local\Share\Logon\Font\Office2007-10\Normal.dotm", strProfilePath & "\", True
strRegFilePath2007 = "\\domain.local\share\Logon\Font\Office2007-10\Outlook2007.reg"
objShell.Run "regedit /s """ & strRegFilePath2007 & """"
'####################### END OF 2007 ######################
Elseif oReg.GetStringValue( _
HKLM, sRegPre & "11.0" & sRegPost, sValueName, sValue) = 0 Then
'###################### START OF 2003 #####################
If objFSO.FileExists (strProfilePath & "normal.dot") Then
If objFSO.FolderExists(strProfilePath & "\old-normal") = False Then
objFSO.CreateFolder strProfilePath & "\old-normal"
End If
objFSO.CopyFile strProfilePath & "\normal.dot", strProfilePath & "\old-normal\"
End If
objFSO.CopyFile "\\domain.local\Share\Logon\Font\Office2003\Normal.dot", strProfilePath & "\", True
strRegFilePath2003 = "\\domain.local\share\Logon\Font\Office2003\Outlook2003.reg"
objShell.Run "regedit /s """ & strRegFilePath2003 & """"
strProgramPath = "Outlook.exe /importprf \\domain.local\Share\Logon\profile.prf"
objShell.Run strProgramPath
'####################### END OF 2003 ######################
Else
MsgBox "Office is not installed on your PC please contact IT Support."
End If
Set objShell = Nothing
|