Login | |
|
 |
RE: read the registry of a remote computer - 7/30/2005 8:23:38 AM
|
|
 |
|
| |
Snipah
Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
Hi The_Apostle21, I use this function very much at work, to read the remote registry to fill the CMDB. Try this, as the large one i use, is at work.... Dim var, strComputer strComputer = 127.0.0.1 var = RegRead("\\" & strComputer & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") MsgBox "Program files are in: " & var
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 7/30/2005 12:56:31 PM
|
|
 |
|
| |
the_apostle21
Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
|
Hi Snipah, thanks for the input. But i copied your code and tried to run it, but i get an error on line 3...is there something else that needs to be a part of the 'RegRead'? thanks again for you help
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 7/30/2005 7:14:35 PM
|
|
 |
|
| |
Snipah
Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
hmmm, i grabbed it from a site which said that this may also do the trick.... Actually what must happen is that the script must access the PC just like a Win32 class...i already had doubts when i saw it, but hey, you never know, unfortunatly i didn't had time left to test it, or else would've seen it was not working... To connect i remember that i used the StdRegProv.... Aha, i found a copy on my USB stick.... pls see below: Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_USERS = &H80000003 Const HKEY_CURRENT_CONFIG = &H80000005 sMethod = "GetStringValue" hTree = HKEY_LOCAL_MACHINE sKey = "SYSTEM\CurrentControlSet\Services\lanmanserver\parameters" sValue = "srvcomment" Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") Set oMethod = oRegistry.Methods_(sMethod) Set oInParam = oMethod.inParameters.SpawnInstance_() oInParam.hDefKey = hTree oInParam.sSubKeyName = sKey oInParam.sValueName = sValue Set oOutParam = oRegistry.ExecMethod_(sMethod, oInParam) CompDescription = oOutParam.Properties_("sValue") '*** place the reg info in CompDescription '*** the function below is to write to the remote reg... using the above var's Function writeRemoteReg() sMethod = "SetStringValue" hTree = HKEY_LOCAL_MACHINE sKey = "SYSTEM\CurrentControlSet\Services\lanmanserver\parameters" sValue = "srvcomment" oInParam.hDefKey = hTree oInParam.sSubKeyName = sKey sValue = Worksheet.Cells(4, 4).Value '*** i use excel to generate info, and write info on the same screen End Function
< Message edited by Snipah -- 7/30/2005 7:17:37 PM >
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 7/30/2005 9:26:22 PM
|
|
 |
|
| |
the_apostle21
Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
|
Hi Snipah, thanks again for your help. but i cannot seem to get CompDescription to pick up any info. i changed the 'strComputer' variable to my computer name and sValue = "srvcomment" to be sValue = "size", simply to match a value that was in the registry. this still returned no value....or is this wrong?? help!!!
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 7/31/2005 12:26:04 AM
|
|
 |
|
| |
Snipah
Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
1) what key are you reading? 2) what is the expected output? 3) what OS are you on? please provide the above, so i can imitate your environment...
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 7/31/2005 6:47:07 PM
|
|
 |
|
| |
the_apostle21
Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
|
I as simply just copying your code straight into a vbs. All i changed is the 'sValue' as stated above...i think this is the key the script is trying to read, but i am not sure. I am on windows xp and that location does exist, probably by default. thanks
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 7/31/2005 9:39:07 PM
|
|
 |
|
| |
Snipah
Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
|
Aha, i took a look at the key...(my bad) the error is in "sMethod = "GetStringValue"" since the key is not a string.... '************************************************************************ 'These are examples For 'sMethod' ' 'GetBinaryValue - reads regisry value of BINARY type 'GetDWORDValue - reads registry value of DWORD type 'GetExpandedStringValue - reads registry value of EXPANDED STRING type 'GetMultiStringValue - reads registry value of MULTI STRING type 'GetStringValue - reads registry value of STRING type 'CreateKey - creates registry key 'SetBinaryValue - writes registry value of BINARY type 'SetDWORDValue - writes registry value of DWORD type 'SetExpandedStringValue - writes registry value of EXPANDED STRING type 'SetMultiStringValue - writes registry value of MULTI STRING type 'SetStringValue - writes registry value of STRING type 'DeleteKey - deletes registry key 'DeleteValue - deleting registry value 'EnumKey - enumerates registry key 'EnumValues - enumerates registry value 'CheckAccess - checks permissions on registry key '************************************************************************
_____________________________
For more information, please see the "Read me First" topic. http://www.visualbasicscript.com
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 8/5/2005 3:54:33 PM
|
|
 |
|
| |
the_apostle21
Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
|
thanks very much Snipah...i will give that a go!!
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 8/10/2005 4:32:28 PM
|
|
 |
|
| |
the_apostle21
Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
|
Hi Snipah, thanks for your help...i have managed to get my script to run without errors!!! the problem is i dont think the sql queries are running. I have created the connection to the database, but im not sure if my syntax is incorrect or the query structure is wrong. here is the script...if you can tell me what i am doing wrong, that would be greatly appreciated... ' Set some variables & constants KEY_VERSION = "Version" KEY_PATCH = "Patch" KEY_HOTFIX = "Hotfix" Const HKEY_LOCAL_MACHINE = &H80000002 ' Create the queries Q_FIRSTSTORE = _ " select top 1 branch_code as FIRST_BRANCH, no_pos_terminals as CURRENT_TILL, ip_address as CURRENT_IP " & _ " from branch " & _ " where " & _ " ip_address <> '0.0.0.0' " Q_COUNT = _ " select count(branch_code) as TOTAL " & _ " from branch " & _ " where " & _ " ip_address <> '0.0.0.0' " Q_CURRENTSTORE = _ " select top 1 branch_code as CURRENT_BRANCH, no_pos_terminals as CURRENT_TILL, ip_address as CURRENT_IP " & _ " from branch " & _ " where " & _ " ip_address <> '0.0.0.0' and branch >= OTHER_BRANCH " Q_REGSET = _ " update AR_VERSION set " & _ " ip_address = ' & CURRENT_IP & ' " & _ " ar_version = ' & VALUE_VERSION & ' " & _ " ar_patch = ' & VALUE_PATCH & ' " & _ " ar_hotfix = ' & VALUE_HOTFIX & ' " & _ " where " & _ " locid = ' & CURRENT_BRANCH & ' " & _ " and " & _ " till_no = ' & CURRENT_TILL & ' " ' Connect to the dataware database Set DW_CONNECT = CreateObject( "ADODB.Connection" ) DATAWARE = "Driver={MySQL ODBC 3.51 Driver};Server=hydra;Port=3306;Database=DATAWARE;Uid=root;Pwd=root;" DW_CONNECT.Open DATAWARE ' ************************************************************************** ' ANGUS & COOTE ' Connect to the A&C database Set AC_CONNECT = CreateObject( "ADODB.Connection" ) ACDATA = "Driver={SQL Server};Server=ROMEO;Database=LIVEACHODATA;Uid=aspuser;Pwd=aspuser;" AC_CONNECT.Open ACDATA ' Find the first store AC_CONNECT.Execute (Q_FIRSTSTORE) ' Count all the stores AC_CONNECT.Execute (Q_COUNT) wscript.echo "total = " & total wscript.quit ' Here we go FIRST_BRANCH = OTHER_BRANCH do until COUNT = TOTAL if FIRST_BRANCH <> OTHER_BRANCH then AC_CONNECT.Execute Q_CURRENTSTORE end if do until CURRENT_TILL = 0 Set oReg=GetObject("winmgmts:\\" & CURRENT_IP & "\root\default:StdRegProv") REG_PATH = "SOFTWARE\Data Group Systems Ltd\AdvanceRetail" oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,REG_PATH,KEY_VERSION,VALUE_VERSION oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,REG_PATH,KEY_PATCH,VALUE_PATCH oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,REG_PATH,KEY_HOTFIX,VALUE_HOTFIX DW_CONNECT.Execute Q_REGSET VALUE_VERSION = "blank" VALUE_PATCH = "blank" VALUE_HOTFIX = "blank" CURRENT_IP + 1 CURRENT_TILL - 1 loop CURRENT_BRANCH = OTHER_BRANCH + 1 COUNT + 1 loop AC_CONNECT.Close
|
|
| |
|
|
|
 |
RE: read the registry of a remote computer - 8/12/2005 11:39:10 AM
|
|
 |
|
| |
the_apostle21
Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
|
Can anyone help me with this at all??
|
|
| |
|
|
|
|
|