We help IT Professionals succeed at work.

Need a VBS to change DWord value in registry.

4,804 Views
Last Modified: 2012-06-27
Can someone write me a VB script to change a value in the registry? This will be placed in a GPO in a Windows2003 domain. I needs to be quiet and it will run at computer logon.
AllowWindowReuse needs to be changed to "0". This cannot be a batch file.

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"AllowWindowReuse"=dword:00000000

Thanks
J
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
on error resume next

' Variable and constant declaration
const HKEY_LOCAL_MACHINE = &H80000002
const HKEY_CURRENT_USER = &H80000001
Const HKEY_USERS = &H80000003

dim oReg
dim strComputer, strKeyPath, strValueName
dim Success


' Registry update code
strComputer = "."
strKeyPath = "Software\Microsoft\Internet Explorer\Main"
strValueName = "AllowWindowReuse"
lngValue=0

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Success = oReg.SetDWordValue(HKEY_CURRENT_USER, strKeyPath, strValueName,strValue, lngValue)


Set oReg=Nothing
lol, beaten to it.

Both methods should work, though yours is shorter and sweeter oBdA!

Author

Commented:
oBdA, The problem is that the users do not have permission to run regedit on the local machines. If it ran at user logon, it would error out since the user does not have the elevated permissions.
I did have a script that was used with the RunAs command, but the CurrentUser was the UserID used in the RunAs script and not the currently logged on user.

Any other ideas? If not, I will award points.
Thanks
J
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
on error resume next

' Variable and constant declaration
const HKEY_LOCAL_MACHINE = &H80000002
const HKEY_CURRENT_USER = &H80000001
Const HKEY_USERS = &H80000003

dim oReg
dim strComputer, strKeyPath, strValueName, lngValue
dim Success


' Registry update code
strComputer = "."
strKeyPath = "Software\Microsoft\Internet Explorer\Main"
strValueName = "AllowWindowReuse"
lngValue=0

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Success = oReg.SetDWordValue(HKEY_CURRENT_USER, strKeyPath, strValueName,lngValue)


Set oReg=Nothing
Though I did leave a bug in the original code... sorry about that, updated (correct) code above.
Oops, I missed your post about running at computer logon.

oBdA is of course absolutely correct - neither of the methods above have any effect when run at computer logon - as the HKCU hive is only loaded for the user.

You can't run either except at user logon, but just because the user does not have access to regedit, this doesn't stop other methods of accessing the registry, and certainly not in the HKCU branch.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.