Changing a Registry Value with a Machine Unique Key
Novell Cool Solutions: Trench
By Bradford Thorpe
|
Digg This -
Slashdot This
Posted: 16 Nov 2001 |
Current version: ZENworks for Desktops 3.2
I was recently asked if I could change the WINS IP on all statically IP coded machines. The WINS IP is a registry value under a key containing a GUID unique for the machine, ie:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\NetBT\Parameters\Interfaces\ Tcpip_{0A4E0998-1952-450C-A6F0-53525083C9DE}]
ZEN cannot dynamically access a unique key but, not one to give up, I found that the GUID is actually a registry value elsewhere:
HKLM\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\NetworkCards\1\serviceName
That gives me something ZEN can use, so that's when I figured this was possible.
I exported the registry value of the GUID into a text file using reg.exe (nic.txt):
REG_SZ %09serviceName%09{0A4E0998-1952-450C-A6F0-53525083C9DE}
I then ran utility called mtr.exe on this to leave me just the GUID in a text file (GUID.txt):
{0A4E0998-1952-450C-A6F0-53525083C9DE}
This I then appended into a pro-forma registry file to give me the key name (wins.reg):
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\NetBT\Parameters\Interfaces\Tcpip_
Which was then appended to the IP value I wanted to change for the WINS address (wins.txt):
]
"NameServerList"=hex(7):31, 30, 2e, 31, 39, 32, 2e, 33, 31, 2e, 32, 38, 00, 00, 00
And this I imported into the registry silently using regedit.
This all runs from batch file via a ZEN app:
@echo off
c:\zenfiles\reg query "HKLM\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\NetworkCards\1\serviceName" > c:\zenfiles\nic.txt
c:\zenfiles\mtr -o$x c:\zenfiles\nic.txt - "[{][^>]*[}]" =\1\r\n > c:\zenfiles\GUID.txt
type c:\zenfiles\GUID.txt >> c:\zenfiles\wins.reg
type c:\zenfiles\wins.txt >> c:\zenfiles\wins.reg
regedit /s c:\zenfiles\wins.reg
Quick reboot and all done. No worries. Next idea is to set the app to run on machines with Static IP addresses only (System requirement). Can be done, but it's a bit trickier.
So another problem solved via ZEN and a little know how. The potential of ZEN never ceases to amaze me. Possibly the most useful tool an organisation could have.
Feel free to e-mail me at bradford@mailandnews.com
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

