Jump to content

Recommended Posts

Posted (edited)

So I adapted and adjusted an AutoIT script found here

http://social.technet.microsoft.com/Forums/en-US/exchangesvrclients/thread/c8b06311-3036-4d51-a028-3ee58ac536fd

The found script was a little slower than expected and it didn't really do anything but tell me what the values were. So I made it into a UDF (just to keep space clean in my scripts), allowed it find what outlook version existed and configured the setting appropriately. This could be adjusted to set Cached Mode to enabled if you so willed it.

; Disable cache mode for Office 2003, 2007, 2010

_ExchangeCachedMode()
Func _ExchangeCachedMode()
CONSTANT $HKCU_Profiles = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
CONSTANT $ExchCachedModeName = "00036601"
CONSTANT $HKCU_MailDefProf = RegRead($HKCU_Profiles,"DefaultProfile")
CONSTANT $HKCU_MailProfile = $HKCU_Profiles & "\" & $HKCU_MailDefProf
; Set initial value for RegEnumKey
$a = 1
While 1
; Parse through each entry under Profiles
$RegKey = RegEnumKey($HKCU_MailProfile,$a)
if @error then ExitLoop
; Set initial value for RegEnumVal
$b = 1
While 2
; Check each profile for the key $ExchCachedModeName
$RegValue = RegEnumVal($HKCU_MailProfile & "\" & $RegKey,$b)
if @error then ExitLoop
; If key matches then process
If $RegValue = $ExchCachedModeName Then
; Read value to see if it needs to be changed, probably not necessary
;$strCachModeSetting = RegRead($HKCU_MailProfile & "\" & $RegKey,$ExchCachedModeName)
; Set cached mode to Disabled
;IF StringInStr($strCachModeSetting,"0x041") = 0 then
Select
     ; Check to see if Outlook 2010 or 2007 is installed, use this first
     Case FileExists("C:\Program Files (x86)\Microsoft Office\Office14\outlook.exe") or FileExists("C:\Program Files (x86)\Microsoft Office\Office13\outlook.exe") _
     or FileExists("C:\Program Files\Microsoft Office\Office14\outlook.exe") or FileExists("C:\Program Files\Microsoft Office\Office13\outlook.exe")
     Regwrite($HKCU_MailProfile & "\" & $RegKey,$ExchCachedModeName,"REG_BINARY",Binary('0x04100000'))
     ; Check to see if Outlook 2003 is installed (but shouldn't be), use secondary
     Case FileExists("C:\Program Files (x86)\Microsoft Office\Office12\outlook.exe") or FileExists("C:\Program Files\Microsoft Office\Office12\outlook.exe")
     Regwrite($HKCU_MailProfile & "\" & $RegKey,$ExchCachedModeName,"REG_BINARY",Binary('0x04000000'))
EndSelect
; Found entry so you can exit and move onto next profile
exitloop
EndIf
; Increment value for RegEnumVal
$b += 1
Wend
; Incremement value for RegEnumKey
$a += 1
Wend
EndFunc
Edited by stamandster
Posted

Thnx for sharing

But wouldn't it be better to search the registry for the path of Office and check if outlook is available in the folder ?

Instead of assuming 32 Bits Office is installed on a X64 system

And Office 13 does not exist http://channel9.msdn.com/Shows/ButWhy/There-is-no-Office-13-But-Why

My Outlook information UDF

#include-once

$HKLM = "HKLM"
$HKCU = "HKCU"
$Architecture = "32 Bits"

If @OSArch = "X64" Then
$HKLM &= "64"
$HKCU &= "64"
$Architecture = "64 Bits"
EndIf

Func _GetOfficeKey($sRemoteComputer = '')
Dim $aKeys[1][9]
If $sRemoteComputer <> '' Then $sRemoteComputer = '\\' & StringReplace($sRemoteComputer, '\', '') & '\'
Local $sRegKey1 = $sRemoteComputer & $HKLM & '\SOFTWARE\Microsoft\Office'
Local $sRegKey2 = $sRemoteComputer & $HKLM & '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
Local $iCount1 = 1, $iCount2 = 1

While 1
$sKey1 = RegEnumKey($sRegKey1, $iCount1)
If @error <> 0 Then ExitLoop
While 1
$ProductID = ''
$ProductName = ''
$DigitalProductID = ''
$sKey2 = RegEnumKey($sRegKey1 & '\' & $sKey1 & '\Registration', $iCount2)
If @error <> 0 Then ExitLoop
$ProductID = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductID')
$Convert = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'OutlookNameVersion')
If StringInStr(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductName'), "2000") Then
$ProductName = "Microsoft® Office Outlook® 2000"
$SPLevel = "N/A"
ElseIf StringInStr(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductName'), "XP") Then
$ProductName = "Microsoft® Office Outlook® XP"
$SPLevel = "N/A"
ElseIf StringInStr(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductName'), "2003") Then
$ProductName = "Microsoft® Office Outlook® 2003"
$SPLevel = "N/A"
Else
$ProductName = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'OutlookNameVersion')
$SPLevel = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'SPLevel')
If $SPLevel = "" Then $SPLevel = "N/A"
EndIf

If StringInStr($ProductName , "2013") Then
$OutlookDefaultProfile = RegRead ($HKCU & "\Software\Microsoft\Office\15.0\Outlook", "DefaultProfile")
Else
$OutlookDefaultProfile = RegRead ($HKCU & "\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging SubSystem\Profiles", "DefaultProfile")
EndIf

$DigitalProductID = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'DigitalProductID')
;$DigitalProductID = Hex(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'DigitalProductID'))
;$BinaryDPID = RegRead($RegKey & '\' & $var, 'DigitalProductId')
$InstallPath = StringTrimRight((RegRead ($sRegKey1 & '\' & $sKey1 & '\Common\InstallRoot', 'Path')),1)
If not FileExists($InstallPath & "\Outlook.exe") Then ExitLoop
$ProductVersion = RegRead($sRegKey1 & '\' & $sKey1 & '\Common\Productversion', 'Lastproduct')
$OfficeLanguage = StringRight(Hex(RegRead($sRegKey1 & '\' & $sKey1 & '\Common\LanguageResources', 'SKULanguage')),4)

If $ProductName = '' Then $ProductName = RegRead($sRegKey2 & '\' & $sKey2, 'DisplayName')

$DigitalProductID = _DecodeProductKey($DigitalProductID, $ProductName)
If $DigitalProductID <> 'BBBBB-BBBBB-BBBBB-BBBBB-BBBBB' Then
ReDim $aKeys[UBound($aKeys) + 1][9]
$aKeys[0][0] = UBound($aKeys) - 1
$aKeys[UBound($aKeys) - 1][0] = $ProductName
$aKeys[UBound($aKeys) - 1][1] = $ProductID
$aKeys[UBound($aKeys) - 1][2] = $DigitalProductID
$aKeys[UBound($aKeys) - 1][3] = $InstallPath
$aKeys[UBound($aKeys) - 1][4] = $ProductVersion
$aKeys[UBound($aKeys) - 1][5] = $OfficeLanguage
$aKeys[UBound($aKeys) - 1][6] = $Architecture
$aKeys[UBound($aKeys) - 1][7] = $SPLevel
$aKeys[UBound($aKeys) - 1][8] = $OutlookDefaultProfile
EndIf

$iCount2 += 1
WEnd
$iCount1 += 1
WEnd
Return($aKeys)
EndFunc ;==>_GetOfficeKey

Func _GetOfficeKey6432($sRemoteComputer = '')
Dim $aKeys6432[1][9]
If $sRemoteComputer <> '' Then $sRemoteComputer = '\\' & StringReplace($sRemoteComputer, '\', '') & '\'
Local $sRegKey1 = $sRemoteComputer & $HKLM & '\SOFTWARE\Wow6432Node\Microsoft\Office'
Local $sRegKey2 = $sRemoteComputer & $HKLM & '\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
Local $iCount1 = 1, $iCount2 = 1

While 1
$sKey1 = RegEnumKey($sRegKey1, $iCount1)
If @error <> 0 Then ExitLoop
While 1
$ProductID = ''
$ProductName = ''
$DigitalProductID = ''
$sKey2 = RegEnumKey($sRegKey1 & '\' & $sKey1 & '\Registration', $iCount2)
If @error <> 0 Then ExitLoop
$ProductID = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductID')
If StringInStr(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductName'), "2000") Then
$ProductName = "Microsoft® Office Outlook® 2000"
$SPLevel = "N/A"
ElseIf StringInStr(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductName'), "XP") Then
$ProductName = "Microsoft® Office Outlook® XP"
$SPLevel = "N/A"
ElseIf StringInStr(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'ProductName'), "2003") Then
$ProductName = "Microsoft® Office Outlook® 2003"
$SPLevel = "N/A"
Else
$ProductName = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'OutlookNameVersion')
$SPLevel = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'SPLevel')
If @Error Then $SPLevel = "N/A"
EndIf

If StringInStr($ProductName , "2013") Then
$OutlookDefaultProfile = RegRead ($HKCU & "\Software\Microsoft\Office\15.0\Outlook", "DefaultProfile")
Else
$OutlookDefaultProfile = RegRead ($HKCU & "\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging SubSystem\Profiles", "DefaultProfile")
EndIf

$DigitalProductID = RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'DigitalProductID')
;$DigitalProductID = Hex(RegRead($sRegKey1 & '\' & $sKey1 & '\Registration\' & $sKey2, 'DigitalProductID'))
$InstallPath = StringTrimRight((RegRead ($sRegKey1 & '\' & $sKey1 & '\Common\InstallRoot', 'Path')),1)
If not FileExists($InstallPath & "\Outlook.exe") Then ExitLoop
$ProductVersion = RegRead($sRegKey1 & '\' & $sKey1 & '\Common\Productversion', 'Lastproduct')
$OfficeLanguage = StringRight(Hex(RegRead($sRegKey1 & '\' & $sKey1 & '\Common\LanguageResources', 'SKULanguage')),4)

$Architecture = "32 Bits"
If $ProductName = '' Then $ProductName = RegRead($sRegKey2 & '\' & $sKey2, 'DisplayName')
$DigitalProductID = _DecodeProductKey($DigitalProductID, $ProductName)

If $DigitalProductID <> 'BBBBB-BBBBB-BBBBB-BBBBB-BBBBB' Then
ReDim $aKeys6432[UBound($aKeys6432) + 1][9]
$aKeys6432[0][0] = UBound($aKeys6432) - 1
$aKeys6432[UBound($aKeys6432) - 1][0] = $ProductName
$aKeys6432[UBound($aKeys6432) - 1][1] = $ProductID
$aKeys6432[UBound($aKeys6432) - 1][2] = $DigitalProductID
$aKeys6432[UBound($aKeys6432) - 1][3] = $InstallPath
$aKeys6432[UBound($aKeys6432) - 1][4] = $ProductVersion
$aKeys6432[UBound($aKeys6432) - 1][5] = $OfficeLanguage
$aKeys6432[UBound($aKeys6432) - 1][6] = $Architecture
$aKeys6432[UBound($aKeys6432) - 1][7] = $SPLevel
$aKeys6432[UBound($aKeys6432) - 1][8] = $OutlookDefaultProfile
EndIf

$iCount2 += 1
WEnd
$iCount1 += 1
WEnd
Return($aKeys6432)
EndFunc ;==>_GetOfficeKey6432

Func _DecodeProductKey($BinaryDPID, $sProductName)
Local $bKey[15]
Local $sKey[29]
Local $Digits[24]
Local $Value = 0
Local $hi = 0
Local $n = 0
Local $i = 0
Local $dlen = 29
Local $slen = 15
Local $Result
Local $sKeyPos = 0x328 * 2 + 3

$Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
$sOLversion = StringSplit("2000/XP/2003/2007", "/")

For $i = 1 to $sOLversion[0]
If StringInStr($sProductName, $sOLversion[$i]) Then
$sKeyPos = 0x34 * 2 + 3
EndIf
Next
$BinaryDPID = StringMid($BinaryDPID, $sKeyPos)
For $i = 1 To 29 Step 2
$bKey[Int($i / 2) ] = Dec(StringMid($binaryDPID, $i, 2))
Next

For $i = $dlen - 1 To 0 Step - 1
If Mod(($i + 1), 6) = 0 Then
$sKey[$i] = "-"
Else
$hi = 0
For $n = $slen - 1 To 0 Step - 1
$Value = BitOR(BitShift($hi, -8), $bKey[$n])
$bKey[$n] = Int($Value / 24)
$hi = Mod($Value, 24)
Next
$sKey[$i] = $Digits[$hi + 1]
EndIf
Next
For $i = 0 To 28
$Result = $Result & $sKey[$i]
Next
Return $Result
EndFunc ;==>_DecodeProductKey

Best regards,Emiel Wieldraaijer

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...