0

Can anyone help/point me in the right direction. I have basic knowledge of coding and I am trying to run a script that will check what version of Outlook that and end user has (Outlook 2013 or 2010). Then depending on what version the user has, it will create a new email profile. I have found a few different scripts and tried to mash them together but I keep getting errors.

My effort is as follows:

Const HKEY_CLASSES_ROOT   = &H80000000
Const HKEY_CURRENT_USER   = &H80000001
Const HKEY_LOCAL_MACHINE  = &H80000002
Const HKEY_USERS          = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005

strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Outlook.Application\CurVer"
strValueName = ""
oReg.GetStringValue HKEY_CLASSES_ROOT, strKeyPath, strValueName, strValue
WScript.Echo strValue

If strValueName >= 15 Then
  "HKCU\Software\Microsoft\Office\" & strValueName & ".0\Outlook\Profiles\" _
    & ProfileName & "\New_O365_1"
  "HKCU\Software\Microsoft\Office\15.0\Outlook" /v DefaultProfile /t REG_SZ /d "New_O36_1" /F
Else
  reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" _ 
    & ProfileName & "\New_O365_1"
  reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles /v DefaultProfile /t REG_SZ /d "New_O365_1" /F"
  reg add "HKCU\Software\Microsoft\Exchange\Client\Options /v PickLogonProfile /t REG_DWORD /d "0" /f"
End If

I have also tried running the If with add reg included but it fails.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • You cannot run external commands from VBScript like that. – Ansgar Wiechers Mar 20 '17 at 16:31
  • Thanks for the reply Ansgar. My plans was to create a script and have it pushed out via a group policy, so when a user opens up their email, this script will run. Would it be better to try using a batch file then? – Alberto Balsam Mar 21 '17 at 09:39
  • Not better, just different. Besides, depending on your environment you may want to use [Group Policy Preferences](https://technet.microsoft.com/en-us/library/dn581922.aspx) instead of scripts for things like that. – Ansgar Wiechers Mar 21 '17 at 10:41
  • ok, thanks again for you advise. – Alberto Balsam Mar 21 '17 at 10:45

0 Answers0