WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Registry
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Connecting to a Registry on a Remote Computer

Keywords: regconnect currentcontrolset 

Using RegConnect Function:

Question:

Can I connect from a Windows NT session to a remote registry (on a 95 machine), grab a value and run away? Does it require any special permissions?

Answer:

  1. Assuming the remote machines are set up for remote administration, then you can use the RegConnect function to connect to remote registries.

  2. If you can do it in RegEdit, you can do it in WinBatch.

  3. I think the remote machine must be set up to allow remote administration and you must have the proper security prevledges. Make it work in REGEDIT first, then try WinBatch.

Logon as Admin and do a RegConnect:

Question:

I have 2 Windows NT 4.0 Workstations. Both Workst. are in the same Domain. In a script, I have written, I want to login from Workst. 1 into Workst. 2 and manipulate the Registry. What module is the right to do this?

Before I can work with the function RegConnect, I must connect to these Workst. with rights of an admin-user. What function can I use to connect to a Workst. under admin-account.

Answer:

Use the wntAddDrive() function. Specify the local drive as @NONE (read the docs for this function) and specify that the connection is not to be persisent. The net-resource will be "\\workstation-name\IPC$", where workstation-name is the name of the remote NT workstation that you want to connect to for registry management functions. If you use @DEFAULT for the username and password then your existing credentials for the workstation on which your script is running will be passed to the remote NT workstation. I recommend that you actually fill in a valid administrator/power-user username and password when you make the connection.

Once you have connected as an administrator to the IPC$ share on the remote NT workstation you will be able to manage its registry. Be sure to disconnect from the IPC$ share after you have unloaded the registry hives from the remote NT workstation.

There is at least one caveat to be aware of. You cannot have any other connections to the remote NT workstation when you try to connect to the IPC$ share. The reason for this is that if any other connections (e.g. network drive letters, shared printer connections, etc...) do exist then you cannot override the credentials that are already in use for those connections. WinNT does not support the simultaneous of multiple sets of credentials between two systems on the network when dealing with the logged on user on the desktop of one system attempting to access resources on a remote system. This has to do with the way that credentials are inherited. If you were to use the wntRunAsUser() function to change your base set of credentials then this problem could be side-stepped.

The wntRunAsUser() function might actually serve better in this case if you know that the administrator username and password are identical on the two NT systems in question. Using wntRunAsUser() to make your script run under this common administrative account's credentials would then allow passthru authentication to happen and the registry manipulation functions should work just fine w/o any special connections being made to the IPC$ share on the remote NT workstation.


Resolving a Remote Netbui Name:

Question:

I know this may sound silly but is there a way to ask a remote machine say 172.16.2.99 to resolve its netbeui name from itself?

i.e. if you ping localhost from the dos prompt then it resolves the netbeui name of itself. Can you do this remotely?

Thoughts??

Answer:

Ummm. If you have remote administration set up, you may be able to do a RegConnect to the other machine and then poke around in its registry.

RegConnect and Error 1503:

Question:

I got this error connecting to some systems using RegConnect:
#1503 Regconnect: invalid computer name
WinBatch 32 97D
WIL ver 24db
Here's my code:
;regtest.wbt:

        filein = FileOpen("c:\progra~1\winbatch\system\wbt\servers.txt", "READ")
        line=FileRead(filein)
        while line != "*EOF*"
           rmtbox=RegConnect("\\%line%", @REGMACHINE)
           key=RegOpenkey(@REGMACHINE, "SOFTWARE\Axean")
           sbkys=RegQueryKeys(key)
           RegCloseKey(key)
           sbkys=StrReplace(sbkys,@tab,@crlf)
           Message("Registry Keys under SOFTWARE\Axean on \\%line%", SBKYS)
           line=FileRead(filein)
        endwhile
FileClose(filein)

servers.txt:
s80bwd01
s80ewd02
s80bkp01
VIAAWD03
VIAAWD01

Connecting to servers 1-3 works OK, but connected to server 4 bombs with Error 1503. Any ideas?

Answer:

Your code looks sick. It looks like you are just looking at the local machine and leaving registry keys open. RegConnect basically does a RegOpenKey on a remote registry, so you have to close that key...

Try...

        filein = FileOpen("c:\progra~1\winbatch\system\wbt\servers.txt", "READ")
        line=FileRead(filein)
        while line != "*EOF*"
           rmtbox=RegConnect("\\%line%", @REGMACHINE)
           key=RegOpenkey(rmtbox, "SOFTWARE\Axean")
           sbkys=RegQueryKeys(key)
           RegCloseKey(key)
           RegCloseKey(rmtbox)
           sbkys=StrReplace(sbkys,@tab,@crlf)
           Message("Registry Keys under SOFTWARE\Axean on \\%line%", SBKYS)
           line=FileRead(filein)
        endwhile
        FileClose(filein)

Connecting to a Remote Registry via a DllCall:

The following sample code shows how to connect to a remote registry with Windows NT 4.0 via a DllCall. Windows 95 and NT 3.51 ought to be similiar:

 bb=BinaryAlloc(16)
 BinaryEODSET(bb,16)
 
 hh=@REGMACHINE ; or @REGUSERS
 compname="\\FRED09"
 
 xx=DllCall("ADVAPI32.DLL",long:"RegConnectRegistryA",lpstr:compname,long:hh,lpbinary:bb)
 
 key=BinaryPeek4(bb,0)
  
 ;or if you do not have the latest version
 ;BinaryPeek4 required 96D or newer
 ; k0=Binarypeek(bb,0)
 ; k1=Binarypeek(bb,1)
 ; k2=Binarypeek(bb,2)
 ; k3=Binarypeek(bb,3)
 ; key=k0 + (k1<<8) + (k2<<16) + (k3<<24)  
 
 
 BinaryFree(bb)
 ;Message("Key is",key)
 
 v=RegQueryValue(key,"software\microsoft\winnt\winlogon[autoadminlogon]")
 
 Message("AutoAdminLogon on %compname% is",v)
 
 RegCloseKey(key)

RegConnect and Trying to Access CurrentControlSet Key

Question:

I'm doing a RegConnect to a remote NT printer server registry (I've got all the remote administration rights).

After the RegConnect, I'm doing a RegQueryKeys to itemize the subkeys under:

    HKLM\System\CurrentControlset\control\print\printers
which is where I can see all the individual printer names itemized, e.g. HP Laserjet 5, HP Laserjet 4/4M, etc.

Trouble is that RegQueryKeys returns the SHARENAMES of these printers, rather than the Printer names above.

This despite the fact that when he looks in the registry, the printer names are there.

Any idea why this is happening?

Answer:

When trying to access the CurrentControlSet key on a remote computer that access is controlled by remote registry rights. This key is located at
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurePipeServers\winreg\AllowedPaths
and gives the allowed paths that a person can access.

Further information can be found at

For Windows XP
http://support.microsoft.com/?kbid=314837

For Windows NT, 2000
http://support.microsoft.com/?kbid=153183


Notes on RegConnect from Windows 95 Machine to Remote Registry:

Thought I'd let you in on a little secret. To use RegConnect in 95, you must have the remote registry feature enabled. Attached is a TechNet article on it. This attached file is copyrighted by Microsoft and I do not claim any responsibility for it use/misuse.

The quasi-legal stuff outta the way, it works. Don't follow the piece about Remote Administration, the Remote Registry Service is what you want.

  
PSS ID Number: Q141460
Article last modified on 10-20-1997
 
95
 
WINDOWS
 

======================================================================
95
WINDOWS
kbnetwork kbhowto
 
---------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Windows 95
---------------------------------------------------------------------
 
SUMMARY
=======
 
This article describes how to install the Remote Administration and Remote
Registry services on a Windows 95-based computer. These services let you
administer file and print sharing and edit the registry remotely (from
another computer on the network).
 
MORE INFORMATION
================
 
Both computers involved in Remote Administration must use the same level of
security (either user-level or share-level security). Remote Administration
contains three components:
 
 - Net Watcher
 - System Monitor
 - File System Administration
 
To use System Monitor, user-level security is required and the Remote
Registry service must be enabled on the computer being remotely
administered. The Net Watcher and File System Administration tools do not
require user-level security or that the Remote Registry service be enabled.
 
Enabling the Remote Administration Service
------------------------------------------
 
1. In Control Panel, double-click Network.
 
2. Click File And Print Sharing. Click both the "I want to be able to
   give others access to my files" and "I want to be able to allow
   others to print to my printer(s)" check boxes to select them, and
   then click OK.
 
3. In Control Panel, double-click Passwords.
 
4. On the Remote Administration tab, click the "Enable remote
   administration of this server" check box to select it.
 
5. Set a password for Remote Administration and then click OK.
 
   NOTE: If you are using user-level security, you do not receive a
   password dialog box. Instead, add users to the list by clicking Add.
 
WARNING: If your computer is configured to use share-level security and
the Remote Administration service is installed, a user is required to
know only a password to remotely administer your computer. To help prevent
unauthorized users from remotely administering computers, consider using
user-level security, which allows access to only specified users.
 
Installing the Remote Registry Service
--------------------------------------
 
To use the Remote Registry service, you must be using user-level security
and have the Remote Administration option enabled. To install the Remote
Registry service, follow these steps:
 
1. If you are already using user-level security, skip to step 5.
 
2. In Control Panel, double-click Network.
 
3. On the Access Control tab, click User-Level Access Control.
 
4. Click OK.
 
5. In Control Panel, double-click Network.
 
6. Click Add, click Service, click Add, and then click Have Disk.
 
7. In the Copy Manufacturer's Files From box, type the path to the
   Admin\Nettools\RemoteReg folder on your Windows 95 CD-ROM, and
   then click OK.
 
8. When the Microsoft Remote Registry service has been added to the list
   of installed components, click OK. When you are prompted to restart
   your computer, do so.
 
NOTE: In order to use user-level security, there must be a Microsoft
Windows NT-based computer or Novell NetWare server on the network to act as
a security provider. If you are using a Windows NT-based computer as your
security provider, you must enable File and Printer Sharing for Microsoft
Networks. If you are using a Novell NetWare server as your security
provider, you must enable File and Printer Sharing for NetWare Networks.
 
Microsoft has made updated drivers for File and Print Sharing available.
For information about obtaining the updated drivers, please see the
following article in the Microsoft Knowledge Base:
 
   ARTICLE-ID: Q128079
   TITLE     : Updated Drivers for File and Printer Sharing Security
 
KBCategory: kbnetwork kbhowto
KBSubcategory: win95
Additional reference words: 95
======================================================================
Keywords	  : win95 kbhowto kbnetwork
Version		  : 95
Platform	  : WINDOWS
=============================================================================
Copyright Microsoft Corporation 1997.


 


Article ID:   W13714
Filename:   Connecting to a Registry on a Remote Computer.txt
File Created: 2003:07:23:12:22:36
Last Updated: 2003:07:23:12:22:36