Solved

VBS script help needed to modify a registry key

Posted on 2010-11-16
6
759 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
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
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…

830 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