Solved

VBS script help needed to modify a registry key

Posted on 2010-11-16
6
731 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now