Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Outlook script

Status
Not open for further replies.

Ricki

Technical User
Feb 25, 2002
64
GB
Hello all... I am a totally new to scripting so please be patient
I need this script to check what version is on outlook and if it’s the right version delete a key and then write a key. I am getting an error on line 20 *invalid char* and I need help







Option Explicit
On Error Resume Next
Dim O2K3
Dim OXP
Dim O2K
Dim WshShell
Dim Profile
Set WshShell = WScript.CreateObject("WScript.Shell")
Set O2K3 = 0
Set OXP = 0
Set O2K = 0
O2K3 = WshShell.RegRead("HKCU\SOFTWARE\Microsoft\Office\11.0\Common\ProductVersion\ProInfo")
OXP = WshShell.RegRead("HKCU\Software\Microsoft\Office\10.0\Common\UserInfo")
O2K = WshShell.RegRead("HKCU\Software\Microsoft\Office\9.0\Common\UserInfo")

If O2K3=1 then WScript.Echo "Detected Outlook 2003"
      WshShell.RegDelete "HKCU\Software\Microsoft\Office\11.0\Outlook\Setup\First-Run"
      WshShell.RegWrite "HKCU\Software\Microsoft\Office\11.0\Outlook\Setup\ImportPRF","\\dsfin\finhome\outlookprf\Outlook-2003.PRF","REG_SZ"
      else If OXP=1 then
      WScript.Echo "Detected Outlook XP"
        WshShell.RegDelete "HKCU\Software\Microsoft\Office\10.0\Outlook\Setup\First-Run"
        WshShell.RegWrite "HKCU\Software\Microsoft\Office\10.0\Outlook\Setup\ImportPRF","\\ dsfin\finhome \outlookprf\Outlook-XP.PRF","REG_SZ"
        else if O2K=1 then
           WScript.Echo "Detected Outlook 2000"
           WshShell.Run "\\dsfin\finhome\OutlookPRF\NEWPROF.EXE -p \\dsfin\finhome\OutlookPRF\Outlook.prf", 0, True
         end if
      end if
    end if
  end if
end sub
check
 
The problem is here:
else if
Either use ElseIf or
Else
If

eg:
If O2K3=1 Then
WScript.Echo "Detected Outlook 2003"
WshShell.RegDelete "HKCU\Software\Microsoft\Office\11.0\Outlook\Setup\First-Run"
WshShell.RegWrite "HKCU\Software\Microsoft\Office\11.0\Outlook\Setup\ImportPRF","\\dsfin\finhome\outlookprf\Outlook-2003.PRF","REG_SZ"
ElseIf OXP=1 Then
WScript.Echo "Detected Outlook XP"
WshShell.RegDelete "HKCU\Software\Microsoft\Office\10.0\Outlook\Setup\First-Run"
WshShell.RegWrite "HKCU\Software\Microsoft\Office\10.0\Outlook\Setup\ImportPRF","\\ dsfin\finhome \outlookprf\Outlook-XP.PRF","REG_SZ"
ElseIf O2K=1 Then
WScript.Echo "Detected Outlook 2000"
WshShell.Run "\\dsfin\finhome\OutlookPRF\NEWPROF.EXE -p \\dsfin\finhome\OutlookPRF\Outlook.prf", 0, True
End If
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the help the script now looks like this, but dos not seem to work

Option Explicit
On Error Resume Next
Dim O2K3
Dim OXP
Dim O2K
Dim WshShell
Dim Profile
Set WshShell = WScript.CreateObject("WScript.Shell")
O2K3 = 0
OXP = 0
O2K = 0
Profile = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows MessagingSubsystem\Profiles\Outlook"
If Profile = 0 Then
WScript.Echo "Email Profile Not Found Creating New Profile"
O2K3= WshShell.RegRead("HKCU\SOFTWARE\Microsoft\Office\11.0\Common\ProductVersion\ProInfo")
err.clear
OXP = WshShell.RegRead("HKCU\Software\Microsoft\Office\10.0\Common\UserInfo")
err.clear
O2K=WshShell.RegRead("HKCU\Software\Microsoft\Office\9.0\Common\UserInfo")
err.clear
If O2K3=1 Then
WScript.Echo "Detected Outlook 2003"
WshShell.RegDelete "HKCU\Software\Microsoft\Office\11.0\Outlook\Setup\First-Run"
WshShell.RegWrite "HKCU\Software\Microsoft\Office\11.0\Outlook\Setup\ImportPRF","\\dsfin\finhome\outlook.prf\Outlook-2003.PRF","REG_SZ"
ElseIf OXP=1 Then
WScript.Echo "Detected Outlook XP"
WshShell.RegDelete "HKCU\Software\Microsoft\Office\10.0\Outlook\Setup\First-Run"
WshShell.RegWrite "HKCU\Software\Microsoft\Office\10.0\Outlook\Setup\ImportPRF","\\ dsfin\finhome\Outlook\Outlookprf\Outlook-XP.PRF","REG_SZ"
ElseIf O2K=1 Then
WScript.Echo "Detected Outlook 2000"
WshShell.Run "\\dsfin\finhome\Outlook\OutlookPRF\NEWPROF.EXE -p \\dsfin\finhome\OutlookPRF\Outlook.prf", 0, True
End If
 
Where do you close "if Profile=0 then"? Why is it Profile=0 ever be possible as you assign profile a string the line above.
 
A better way to get the actual version of outlook....

Code:
set ol = getobject(,"outlook.application")

If Mid(ol.version,3,1) <>"." then
	majorVer= Left(ol.Version,1)
Else
	majorVer= Left(ol.Version,2)
End If

MsgBox majorVer

If the PC was an upgrade you could have multiple version registry entries and it will be best to actually query Outlook.

I hope you find this post helpful.

Regards,

Mark
 
Thanks Mark, but I am not trying to get the version show on screen, I need to read a line in the registry and on confirmation either del the line and write a new one to avoid outlook running the startup process for each user....
 
The point I was making here was that you can determine which version of outlook is installed so you can then use that information to determine which registry path you need to go to. The only difference in your registry paths above is the 11.0, 10.0, 9.0. The script I posted will determine which one is the correct number.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top