Question : vbscript problem, copying normal.dotm is overwritten by the outlook initial config wizard

Hi all,

ive been writing a quite nifty script that checks OS version and Office vesrion and sets the default font for word and outlook and if on 2003 creates your outlook profiles
(currently limited to XP and win 7 though but can easily be adapted)

it also creates the templates folder if it hasnt already been created

ive tested it on any os thats running office 2003 and it works fine

now the problem is when a user logs in for the very first time the script will run create the folders and copy the normal.dotm and reg settings in but when outlook or word are opened for the first time, they are overwritten by outlooks default settings created during the wizard

the only thing i thought of doing is running outlook putting in a delay then running the rest
when outlooks opened for the first time, will it create its templates and default reg settings before the wizard is completed by the user?

thanks for any help
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
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

Answer : vbscript problem, copying normal.dotm is overwritten by the outlook initial config wizard

I would agree with a registry entry

Chris
Random Solutions  
 
programming4us programming4us