Adding DWORD
Hi,
I am trying to add a threshold value to HKCU through a script. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings , i need to create the value name Receivetimeout and give the valuedata . I tried the runonce script, it works as a admin, but fails for a locked down user. Here is the script, please tell me if I need to make any changes.
Runonce Script:
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\RunOnce"
strValueName = "ReceiveTimeout"
strValue = "C:\Applications\BusinessObjects\ReceiveTimeout.vbs"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
the Receivetimeout.vbs contains
Option Explicit
Dim WSHShell, RegKey
set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\"
WSHShell.RegWrite RegKey & "Receive Timeout", 3600000, "REG_DWORD"
'WScript.Echo WSHShell.RegRead(RegKey & "Receive Timeout")
Please let me know, if I am wrong somewhere.
Thanks
Answers (6)
Either do it through an MSI, or add an equivalent key in HKCU through Active Setup.
It makes sense for the RunOnce script not to work for a locked down user, since you're trying to write a HKLM registry key.
Using either runonce or ActiveSetup, you'll always need to run the script that puts everything in place as an admin once on each machine. The script that gets triggered (receivetimeout.vbs) then runs for each user
In finishing, using the runonce key like this is not a good solution for your problem, since the receivetimeout.vbs will only run once the next time a user logs in, an not for each user.
Run Once or Active setup key will not be able to perform any task which require elevated privileges. So either do it through MSI or add an equivalent key in HKCU through Acrive Setup.
Comments:
-
Thanks so much, your method worked :) - shamu99 12 years ago
Push the run once script using admin\system account how are you deploying this?
Comments:
-
I am deploying through Radia. I have given radia the rights for it to install anything as an admin. - shamu99 12 years ago
A great way to push registry keys is to grab one of the simple Microsoft Fix It solutions and modify it with ORCA.
http://support.microsoft.com/kb/255905