Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to apply registry with logon script

Posted on 2007-03-27
5
319 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

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fabric 1 32
AD and Exchnage 2010 Photos 3 42
gpo help required 4 29
Powershell query for OU membership 5 35
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

838 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