Solved

How to apply registry with logon script

Posted on 2007-03-27
5
312 Views
Last Modified: 2011-10-03
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.
0
Comment
Question by:kimakabane
  • 3
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18799006
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


0
 

Author Comment

by:kimakabane
ID: 18799144
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.
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 18799234
Change the "IF" to this...
If IsNull(strValue) Then
0
 

Author Comment

by:kimakabane
ID: 18799415
worked... Thanks!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18799419
:^)
Happy to help!
0

Join & Write a Comment

#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now