Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add registry key/value 3

Status
Not open for further replies.

bonafide247

IS-IT--Management
May 28, 2003
76
US
VBScript padawan here.

* Active Directory Domain - 2003
* Windows XP SP3 computers

I want to push out a registry change via VBScript. This code runs fine on accounts with admin access, but will not run for standard users. My current logon script, which maps printer/drives/etc, runs fine on all accounts. I am just having trouble getting this registry entry created.

Is there any additional code, access, or anything else required for the code to work? Thank you for your help!

------------------------------------------------------------
Code:
[b]const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\windows\currentversion\netcache"
strValueName = "FormatDatabase"
dwValue = 1
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue[/b]
-----------------------------------------------------
 
Try making it part of a login script for the computer...I believe those run under "System" which should allow this script to work.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
In fact, put the code in a startup script instead of a logon script.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The script, when run manually, does not make the registry changes to normal users. However, it will make changes for admin accounts. I do not want to give normal users elevated privilages to the registry.

Anything I should doublecheck on?
 
Did you try my suggestion ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Probably he/she doesn't know what a _startup_ script is! Also it does not elevate anybody to any elevated unwarranted privileges.
 
PHV, sorry, I did try that suggestion. The script will not execute either manually or via startup. I am assuming the vbscript will not make those registry changes for a normal user.

Tsuji, why did you post that response? It sounds a bit mean spirited, and honestly, quite arrogant.
 
That is the honest conclusion from your response. People are really _arrogant_ here it seems recently.
 
Well...I will definitely be the first to admit that I am an amateur when it comes to scripting, which is why I have posted.

My experience with VBScript is very limited, and I am still learning. I've been able to run a startup script to log network drives, printers, and install software in the same environment, but unable to make registry changes. If you have any suggestions, I would be happy to hear them. Thanks for your time.
 
My arrogance rests on my non-response. If I response, that proves I am not. In your response, short though it may be, you describe all those behaviours with the script being executed in some admin or normal user context. That is not what startup script is meant for. I point it out so that PHV may give you further advice in that direction. Rather than what you elected to post, I would actually look up what specificity of startup script from the documentation or google it up. Learning? who is not. I wouldn't be the last one to admit. That's nothing special worthy of mentioning.
 
Thanks for your advice Tsuji. Have a wonderful 4th.
 
Tsuji, after some more digging, I have come to understand in a GPO context...the differences between a startup and a logon script.

Computer Configuration = startup script.
User Configuration = logon script.

I was able to get the script working after using Computer Configuration --> Startup Script and applied this to a computer object.

I misinterpreted the spirit of your first comment, and I apologize for overreacting. You were right. Thanks to both for your assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top