Solved

VBS script help needed to modify a registry key

Posted on 2010-11-16
6
770 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 500 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
Independent Software Vendors: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

738 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