Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Problem/Query regarding remote registry

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,42370
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem/Query regarding remote registry
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Problem/Query regarding remote registry - 1/23/2007 2:58:22 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
We have created a script at work that connects to the registry on remote PC's and pulls some info regarding build versions (This is a stamp that we include in our builds for version comtrol) and exports to an excel spreadsheet so we can see which PC's require build updates.  Problem is when we connect with the script it creates a users profile of the person who is running the script as it reads the registry.  I hope that makes some sense!!

  Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strTarget & "\root\default:StdRegProv")
  strKeyPath = "SOFTWARE\BuildVersion"
  strValueName = "BuildID"
  objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strBuildID


Is there another way to get this info from the remote registry without a profile being created?

Thanks is advance!
 
 
Post #: 1
 
 RE: Problem/Query regarding remote registry - 1/23/2007 3:27:49 AM   
  dm_4ever


Posts: 2722
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
How does the profile created affect your script?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ninjamaster)
 
 
Post #: 2
 
 RE: Problem/Query regarding remote registry - 1/23/2007 3:58:49 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
quote:

ORIGINAL: dm_4ever

How does the profile created affect your script?


The script runs no problems all the way through.  It's just that when we connect to each PC (And I'm talking about 4000+) to read the registry it appears to make a new profile with my name (As I'm the one running the VBS but if my colleague runs it a profile of his name is created) based on the default user profile.

As stated it doesn't cause the script to stop working or indeed cause the PC any problems just wondering/hoping there is another way to read the remote registry without creating these profiles.

I understand the registry has to be "read" by someone, so is there a way to tell the script to use a certain account (ie local administrator) to read the registry instead of the script runner?

:)

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Problem/Query regarding remote registry - 1/23/2007 4:03:05 AM   
  twilliamsen

 

Posts: 208
Score: 0
Joined: 1/18/2007
Status: offline
I assume it is this

Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strTarget & "\root\default:StdRegProv")

You are impersonating yourself on the target machine.

(in reply to ninjamaster)
 
 
Post #: 4
 
 RE: Problem/Query regarding remote registry - 1/23/2007 4:03:39 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
Do a google search for "vbscript wmi alternate credentials".

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ninjamaster)
 
 
Post #: 5
 
 RE: Problem/Query regarding remote registry - 1/23/2007 4:06:41 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
quote:

ORIGINAL: twilliamsen

I assume it is this

Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strTarget & "\root\default:StdRegProv")

You are impersonating yourself on the target machine.


That's what we are assuming also.  Just wondering if there was a way to tell the script to use someone else.  I'll try ebgreen's search.

:D

(in reply to twilliamsen)
 
 
Post #: 6
 
 RE: Problem/Query regarding remote registry - 1/23/2007 4:11:29 AM   
  twilliamsen

 

Posts: 208
Score: 0
Joined: 1/18/2007
Status: offline
take a peek at this....


http://www.microsoft.com/technet/scriptcenter/guide/sas_reg_ojns.mspx

(in reply to ninjamaster)
 
 
Post #: 7
 
 RE: Problem/Query regarding remote registry - 1/23/2007 4:17:26 AM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
quote:

ORIGINAL: twilliamsen

take a peek at this....


http://www.microsoft.com/technet/scriptcenter/guide/sas_reg_ojns.mspx


That's not a million miles away from what our script is currently doing.  But that will still create the profile because of

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &  strComputer & "\root\default:StdRegProv")

and as soon as the line

objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, strEntryName, strValue

is executed the profile is created to set (or in my case get) the stringvalue.  I've found some info from google on alternate credentials that I'll have a look at tomorrow.  Going home.  Brain tired.....

(in reply to twilliamsen)
 
 
Post #: 8
 
 RE: Problem/Query regarding remote registry - 1/23/2007 4:38:45 AM   
  Country73


Posts: 735
Score: 10
Status: offline
Here's a different route for extracting information from a remote registry:
http://www.visualbasicscript.com/fb.aspx?m=28367

I'm not a big fan of WMI and how long it usually takes to run.

(in reply to ninjamaster)
 
 
Post #: 9
 
 RE: Problem/Query regarding remote registry - 1/23/2007 3:27:27 PM   
  dm_4ever


Posts: 2722
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Did you do the search ebgreen suggested?  You should have found "WbemScripting.SWbemLocator" object that lets you specify alternate credentials.

strKeyPath = "SOFTWARE\BuildVersion" 
strValueName = "BuildID"

Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMI = SWBemlocator.ConnectServer(strComputer ,"root\default",strUser, strPwd)
Set objRegistry = objWMI.Get("StdRegProv")

objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strBuildID

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ninjamaster)
 
 
Post #: 10
 
 RE: Problem/Query regarding remote registry - 1/23/2007 7:45:43 PM   
  ninjamaster

 

Posts: 107
Score: 0
Joined: 1/23/2007
Status: offline
quote:

ORIGINAL: dm_4ever

Did you do the search ebgreen suggested?  You should have found "WbemScripting.SWbemLocator" object that lets you specify alternate credentials.

strKeyPath = "SOFTWARE\BuildVersion" 
strValueName = "BuildID"

Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMI = SWBemlocator.ConnectServer(strComputer ,"root\default",strUser, strPwd)
Set objRegistry = objWMI.Get("StdRegProv")

objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strBuildID


I did thanks and this works perferctly.  Implemented it this morning and script running as sweet as.

Thanks Guys!!

(in reply to dm_4ever)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem/Query regarding remote registry Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts