问题
I have the following problem. At work I'm working on a domain and i'm writing a batch script that, among other things, queries remotely windows registry from other machines in the domain. There, things work ok. That is, a query like:
reg query \\MACHINE1\HKLM\SYSTEM
works just fine. However while doing some testing at home I just can't access windows registry in computer A from computer B. The same command in my small 2 PC network result in:
ERROR: Cannot find network path
Or something similar, not sure how to translate it from Spanish: ERROR: No se ha encontrado la ruta de acceso a la red. One machine is running Windows 8.1 Pro 32-bits, the other Windows 7 Pro 64-bits. They can ping each other. They both have shared folders and when clicking on Network icon both machines show up, as well as the shared resources.
What am i missing???
Thanks in advance!
回答1:
You need to do this as a local admin on the machine being read. See runas
command.
回答2:
Not sure what is preventing you from running reg query
against remote machines, but I do have a potential workaround to suggest until you figure out what sort of security restriction is blocking you. You can invoke the WMI StdRegProv class via wmic
. It's a little tricky, and I don't even remember where I first learned about this functionality, but it is useful where remote registry calls are directly blocked but WMI remote procedure calls are not.
@echo off
setlocal
set "remotePC=machine1"
set "remoteUser=username or domain\username"
set "remotePass=password"
set "HKCR=&H80000000"
set "HKLM=&H80000002"
set "HKU=&H80000003"
set "HKCC=&H80000005"
set "wmic=wmic /node:%remotePC% /user:%remoteUser% /password:%remotePass%"
rem // to enumerate keys in \\HKLM\SYSTEM, do:
%wmic% class stdregprov call EnumKey hDefKey="%HKLM%" sSubKeyName="SYSTEM"
rem // to enumerate values in \\HKLM\Software\Microsoft\Windows\CurrentVersion\Run, do:
%wmic% class stdregprov call EnumValues hDefKey="%HKLM%" sSubKeyName="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"
rem // note the double backslashes in sSubKeyName above
Besides EnumKey
and EnumValues
, there are more methods you can call -- GetDWORDValue
, GetExpandedStringValue
, DeleteKey
, and many others. See the MSDN StdRegProv class documentation for full details.
回答3:
Managed to fixed the problem. As I mentioned problem was with a small 2 PC home network used for testing (configured as Workgroup, Windows 7 64 bits and Windows 8.1 32 bits). Here is what I did:
- Enable Administrator account on both PCs and set them with same pwd.
- Then, accessed a shared resource of say computer A from computer B. While at computer B computer A asks for user name and pwd. I entered it and ask the system to save it. Repeat the same operation but in the opposite direction.
Now I can reg query, add or delete from A to B and from B to A.
Thanks for your answers. Happy Holidays!
来源:https://stackoverflow.com/questions/34384378/reg-query-remote-computer-not-working