Link to home
Start Free TrialLog in
Avatar of kimakabane
kimakabaneFlag for Japan

asked on

How to apply registry with logon script

I'd like to apply the following registry with vbs on particular OU.
Since this is under HKCU should be ran as logon script.

http://support.microsoft.com/kb/319206/en-us
HKEY_CURRENT_USER\Software\Microsoft\Exchange\Exchange Provider
Value name: Closest GC
Data type: REG_DWORD
Radix: Hexadecimal
Value data: 0x00000001

Script has to determine if this registry is already exists, and if so should skip the process because I don't want to re-apply the registry.
Please help. I'm not good at scripting.
Avatar of sirbounty
sirbounty
Flag of United States of America image

This should do it...

Const HKEY_CURRENT_USER = &H80000001
 
Dim objReg:Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Exchange\Exchange Provider"
strValueName = "Closest GC"
oReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
If strValue="" Then
  objReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath, strValueName, 1
End If
Set objReg=Nothing


Avatar of kimakabane

ASKER

Hi,

I copy pasted the script and create .vbs but nothing has created under the key.
Also I had to correct
oReg.GetDWORDValue
to
objReg.GetDWORDValue
I think this is just a typo.

No error message, but nothing created. I'm sure that I have local admin rights.
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
worked... Thanks!
:^)
Happy to help!