Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBS script help needed to modify a registry key

Posted on 2010-11-16
6
Medium Priority
?
800 Views
Last Modified: 2012-05-10
Hi,

Could someone help me out to write a quick vbs script that will change the following keys on the registry.


1.      Using a Registry Editor such as Regedt32.exe, open this key:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Styles

Note If the Styles key is not present, create a new key that is called Styles.

2.      Create a new DWORD value called "MaxScriptStatements" under this key and set the value to the desired number of script statements. If you are unsure of what value you need to set this to, you can set it to a DWORD value of 0xFFFFFFFF to completely avoid the dialog.

0
Comment
Question by:llarava
[X]
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
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:ragnarok89
ID: 34145595
Although this does not have the "check if registry key exists", it does show an example of creating a reg entry without calling another executable. If the registry entry already exists, it is simply re-written with the same info.

Option Explicit
Dim objShell, strRoot, strModify, strDelete
strRoot = "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Styles"
' Create the Shell object
Set objShell = CreateObject("WScript.Shell")
strModify = objShell.RegWrite(strRoot,"0xFFFFFFFF", "DWORD")
strModify = null
WScript.Quit
0
 
LVL 7

Accepted Solution

by:
rogerard earned 2000 total points
ID: 34145637
This should do it:
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Software\Microsoft\Internet Explorer\Styles"
 
strValueName = "MaxScriptStatements"
dwValue = 0xFFFFFFFF
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

Open in new window

0
 

Author Comment

by:llarava
ID: 34147159
Our users are do NOT have admin rights to their computers. I am facing the following problem since the script or the MSI provided by MS http://support.microsoft.com/default.aspx?scid=kb;en-us;175500

Since the changes are being applied to the HKEY_CURRENT_USER\Software\ neither the script or the MSI are working since the admin rights are needed.

The problem is that if a deploy the script or the MSI with SCCM (deployment tools) I can choose to run the script/MSI with admin rights however since the change is applied to the HKEY_CURRENT_USER\ hive I guess the change it is NOT applied correctly.

Is there anyway that I could make this change?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:rogerard
ID: 34147584
lookup the syntax of the runas command to see how to run it as the local administrator on the workstations

this will fix the problem by running the script under the context of the local admin, allowing full access to the system files and registry
0
 

Author Comment

by:llarava
ID: 34147618
The run as will execute the script as whatever user your are "running as..." the script will be making changes to the HKEY_CURRENT_USER\ hive so the script has to be executed as the "user" for which you want the changes to be applied.

If your execute the script or the MSI with run as then chages are not applied to the HKEY_CURRENT_USER\

Do you know what I mean...
0
 
LVL 7

Expert Comment

by:rogerard
ID: 34147705
OK.  How about having two scripts, one that you run as an administrator to change write permission on the necessary key, then the other to run as the user to change the key, then change the permissions back.

This link, http://support.microsoft.com/?kbid=237607, shows how to use regini.exe to change the permissions.
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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

715 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