bsharath
asked on
Script that changes the cached mode status. need help with this script.
Hi,
The below script changes the status of cached mode of Outlook. when changed from false to true and true to false.
Can i have help with some changes. To have a message stating staus now is enabled. Going to disable. To enable it back please run again.
And the script that to be changed in such a way that if enabled it has to get disabled and if disabled it has to be enabled.
Any help is greatly appretiated.
Regards
Sharath
The below script changes the status of cached mode of Outlook. when changed from false to true and true to false.
Can i have help with some changes. To have a message stating staus now is enabled. Going to disable. To enable it back please run again.
And the script that to be changed in such a way that if enabled it has to get disabled and if disabled it has to be enabled.
Any help is greatly appretiated.
Regards
Sharath
' Script to enable - or - disable Outlook Cache Mode.
'
Option Explicit
'On error resume next
' Environment specific Consts
' Path to your log file
Const LogFile = "\\im\logs\Cached.log"
' Whether to enable Cache Mode on clients where this is currently disabled
Const EnableCacheMode = true
' Whether to disable Cache Mode on clients where this is currently enabled
Const DisableCacheMode = false
' Setting both EnableCacheMode and DisableCacheMode to false will report the status of ol cached mode on the client only
' End Environment specific Consts
' Registry Constants
Const HKCU = &H80000001
Const RegKeyProfiles = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
Const RegKeyName = "13dbb0c8aa05101a9bb000aa002fc45a"
Const RegValueName = "00036601"
' Global Variables
dim arrDisabledValue : arrDisabledValue = Array(&H04,&H00,&H00,&H00) ' value to set disabled
dim arrEnabledValue : arrEnabledValue = Array(&H84,&H01,&H00,&H00) ' value to set enabled (w/o PF's)
dim arrEnabledValueWithPF : arrEnabledValueWithPF = Array(&H84,&H05,&H00,&H00) ' value to set enabled with Public Folder Favourites
Dim ArrAllSubKeys, arrValueTypes, arrValues, objSubKey, subval, sValue, iret
Dim fullKeyPath
Dim oRegWMIProv
Dim oFso
Dim oLogFile
Dim oNet
Dim sComputerName
Dim sUserName
if EnableCacheMode and DisableCacheMode then
Wscript.echo "Invalid configuration! You cannot have both EnableCacheMode and DisableCacheMode enabled at the same time. Quitting.."
Wscript.quit(-1)
end if
Set oNet = CreateObject("Wscript.Network")
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oRegWMIProv = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
sUserName = oNet.UserName
sComputerName = oNet.ComputerName
if oFso.FileExists(LogFile) then
Set oLogFile = oFso.OpenTextFile(LogFile, 8)
else
Set oLogFile = oFso.CreateTextFile(LogFile, False)
oLogFile.Writeline "ComputerName,UserName,ProfileName,OLCachedModeStatus"
end if
' List all subkeys (Profiles)
oRegWMIProv.EnumKey HKCU, RegKeyProfiles, ArrAllSubKeys
For Each objSubKey In arrAllSubKeys ' looping profiles
Wscript.echo "Profile " & objSubKey
fullKeyPath = RegKeyProfiles & "\" & objSubKey & "\" & RegKeyName
' enum all values under the cached mode reg id key
oRegWMIProv.EnumValues HKCU, fullKeyPath, arrValues, arrValueTypes
for each subval in arrValues
' if the sub value is the one we are interested in then process it
If subval = RegValueName Then
oRegWMIProv.GetBinaryValue HKCU, fullKeyPath, subval, sValue
If (sValue(0) = arrDisabledValue(0)) AND (sValue(1) = arrDisabledValue(1)) AND (sValue(2) = arrDisabledValue(2)) AND (sValue(3) = arrDisabledValue(3)) Then
oLogFile.WriteLine sComputerName& "," & sUserName& "," & objSubKey& "," & "Cached Mode Disabled"
Wscript.echo sComputerName& "," & sUserName& "," & objSubKey& "," & "Cached Mode Disabled"
if EnableCacheMode then
Wscript.echo objSubKey & " Disabled (enabling)"
iret = oRegWMIProv.SetBinaryValue (HKCU,fullKeyPath,RegValueName,arrEnabledValue)
oLogFile.WriteLine sComputerName& "," & sUserName& "," & objSubKey& "," & "Cached Mode Now Enabled"
end if
else
oLogFile.WriteLine sComputerName & "," & sUserName& "," & objSubKey & "," & "Cached Mode Enabled"
Wscript.echo sComputerName& "," & sUserName& "," & objSubKey& "," & "Cached Mode Enabled"
if DisableCacheMode then
Wscript.echo objSubKey & "Enabled (disabling)"
oLogFile.WriteLine sComputerName& "," & sUserName& "," & objSubKey& "," & "Cached Mode Now Disabled"
iret = oRegWMIProv.SetBinaryValue (HKCU,fullKeyPath,RegValueName,arrDisabledValue)
End If
End If
End If
Next
Next
oLogFile.Close()
Set oRegWMIProv = Nothing
Set oFso = Nothing
Set oLogFile = Nothing
Set objSubKey = Nothing
Set oRegWMIProv = Nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This one is tough to rewrite because of the need to enumerate the profiles, determine the current state and then toggle it based on the Reg_Binary value. Can you explain the need for this? Why don't you use group policy and force the setting you want.
ASKER
We are iin the Exchange rollout.
When the user runs the profile manager he first needs to disable cache and then once done enable it back
When the user runs the profile manager he first needs to disable cache and then once done enable it back
ASKER
If i can get 2 script 1 for enablingg and another for disabling i am ok
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. Due to emergency
i changed the false to true and visse versa and saved into 2 vbs files and renamed as enable and disable. Now problem resolved...:-)
i changed the false to true and visse versa and saved into 2 vbs files and renamed as enable and disable. Now problem resolved...:-)
ASKER
At present we need to change the false to true and vise versa