Tuesday, January 25, 2011

Microsoft Office - Disabling AutoFormat "Internet and network paths with hyperlinks" option through the registry.



Recently, at my place of business, I had to find an automatic way of disabling the "Internet and network paths with hyperlinks" option in Outlook 2007.  I wish it was as simple as setting a registry setting from "1" to "0" but it was a little beyond that.  The following vbscript is what was written and pushed out to our users through group policy:

' Constants used in this script
Const HKCU = &H80000001 'HKEY_CURRENT_USER
Const ToggleAutoFormat = &H00000010 ' Auto Format flag
Const ToggleAutoFormatInv = &H11111101 ' Auto Format flag inverse
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Office\12.0\Word\Data"
strValueName = "SettingsWordMail"
' Get the binary value in question
oReg.GetBinaryValue HKCU, strKeyPath, strValueName, strValue
bitLocation = -1
' If this setting was not found, early out
if IsNull( strValue ) then
    WScript.Quit
end if
' go through the binary data and find our current setting
For i = lBound(strValue) to uBound(strValue) - 4
    'StdOut.Write "(" & i & ")" & strValue(i) & "|"
    'StdOut.Write strValue(i) & "|"
    if strValue(i) = 135 and strValue(i + 1) = 255 and strValue(i + 2) = 255 then
        'StdOut.Write "Found the troubled bit at " & (i + 3) & ": " & strValue(i + 3)
        bitLocation = i + 3
    end if
Next
' Did not find the bit we are looking for, early out
if bitLocation = -1 then
    WScript.Quit
end if
' Set the bit to off
newBit = strValue(bitLocation) And ToggleAutoFormatInv
' Write the new value into the registry only if this setting is toggled on
if newBit <> strValue(bitLocation) then
    strValue(bitLocation) = newBit
   
    ' Write the value back to the registry
    oReg.SetBinaryValue HKCU, strKeyPath, strValueName, strValue
end if

5 comments:

  1. What would one need to do to reverse thsi and recheck the option in outlook if it is required to back out of this change?

    ReplyDelete
  2. I'm working in Outlook 2010, by the way so I've switched Software\Microsoft\Office\12.0\Word\Data to Software\Microsoft\Office\14.0\Word\Data

    ReplyDelete
  3. How did you push it out through Group Policy for your users?

    Thanks,

    Tee

    ReplyDelete
  4. I tried the above vbscirpt via GPO but it did not work. I wonder how this guy made it work on his network. It will be very nice if he can come back and give us the information.

    Thanks,

    Tee

    ReplyDelete
  5. Verified working for Outlook 2010, and this helps satisfy V-41493 of the Outlook STIG. Thanks!!

    ReplyDelete