GregThompson Posted April 8, 2008 Posted April 8, 2008 Ok, so I wrote this script, it works on some machines in my company, but not others, wtf? I don't get how the remote registry, which is available on all our machines I can get to thru regedit, but when I run this file, some report back, others error out??? Any help much appreciated. Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "el044552" Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\default:StdRegProv") strKeyPath = "SYSTEM\Setup" strValueName = "OEMDuplicatorString" objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue If IsNull(strValue) Then Wscript.Echo "The registry key does not exist." Else Wscript.Echo strValue End If
weaponx Posted April 8, 2008 Posted April 8, 2008 (edited) Here is the problem, you aren't using AutoIt. Ptrex will tell you to add in a COM error handler. Const $HKEY_LOCAL_MACHINE = "&H80000002" $strComputer = "el044552" Dim $objRegistry = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\default:StdRegProv") $strKeyPath = "SYSTEM\Setup" $strValueName = "OEMDuplicatorString" $objRegistry.GetStringValue($HKEY_LOCAL_MACHINE,$strKeyPath,$strValueName,$strValue) If $strValue = "" Then ConsoleWrite( "The registry key does not exist.") Else ConsoleWrite( $strValue) EndIf EDIT: Also the Autoit Reg* functions do work remotely It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights on NT/2000/XP/2003, or if you are using a 9x based OS the remote PC must have the remote registry service installed first (See Microsoft Knowledge Base Article - 141460). Edited April 8, 2008 by weaponx
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now