Jump to content
Sign in to follow this  

WMI Read Registry Remotely...

Recommended Posts

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."
    Wscript.Echo strValue
End If

Share this post

Link to post
Share on other sites

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"

If $strValue = "" Then
ConsoleWrite( "The registry key does not exist.")
ConsoleWrite( $strValue)

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 by weaponx

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...