Logon and Get MAC Address
Keywords: MAC address NIC logon
Thought I'd share a cool tool I wrote 'cause I was too lazy to go floor-to-floor to get the MAC addresses of NT servers. Some caveats...Enjoy!
- Runs fine under NT as is. Needs File and Print Sharing in 95 along with the remote registry service and some other stuff. See MS TEchnet article Q141460 (don't know if it's against regs to copy copyrighted material).
- Have been told that there are some quirks, but haven't noticed any.
- You must have Administrator privileges on destination machine to connect to the remote registry.
-DaG
;===================================snip====================== :BeginProgram :IsItRunning Sounds(0) ProgVer="RegNet v2.0" LongProgVer="%ProgVer% Remote Registry Network Query" AlreadyOpen=WinExist(ProgVer) if AlreadyOpen == @TRUE then goto End CheckForKey=IsKeyDown(@SHIFT) if CheckForKey == @YES ProgDebug = AskYesNo(ProgVer,"Would you like Debug Mode turned ON?") If ProgDebug == @YES Debug(@ON) ErrorMode(@ON) endif endif :SetupEnvironment LF=@CRLF ErrorMode(@OFF) WilHome=DirHome() CurrentDir=DirGet() WinDir=DirWindows(0) SysDir=DirWindows(1) CurrentTime=TimeDate() :DetermineOS BoxOpen(ProgVer,"Determining Operating System") PCOS=WinMetrics(-4) if PCOS != 4 || PCOS != 5 then goto NoOS BoxOpen(ProgVer,"Getting domain information. Please wait...") if PCOS==4 then AddExtender("wwwNT34I.dll") if PCOS==5 then AddExtender("www9X34I.dll") if param0 > 0 domain = StrUpper (Param1) else if PCOS==4 then domain = StrUpper (wNTUserInfo(1)) if PCOS==5 then domain = StrUpper (w9XUserInfo(1)) end if :ListServers BoxText("Getting list of available machines.") if PCOS==4 then Machines = wNTServerList("",domain,4096) if PCOS==5 then Machines = w9XServerList("",domain,4096) gosub ComputerNameDialog if ComputerName == "" then goto Error1 BoxText("Attempting to connect to remote registry on%LF%%ComputerName%. Please be patient...") Machine=RegConnect(ComputerName, @REGMACHINE) if Machine == @FALSE then goto Error2 ServiceName = RegQueryValue(Machine,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\1\[servicename]") Title = RegQueryValue(Machine,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\1\[title]") MACaddress=RegQueryBin(Machine,"SOFTWARE\Description\Microsoft\Rpc\UuidTemporaryData\[NetworkAddress]") IPRegKey=RegOpenKey(machine,"SYSTEM\CurrentControlSet\Services\%ServiceName%\Parameters\Tcpip") IPaddress=RegQueryMulSz(IPRegKey,"[IPAddress]",@tab) Gateway=RegQueryMulSz(IPRegKey,"[DefaultGateway]",@tab) SubNet=RegQueryMulSz(IPRegKey,"[SubnetMask]",@tab) HostName = RegQueryValue(machine,"System\CurrentControlSet\Services\TCPIP\Parameters[Hostname]") IPdomain = RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Services\TCPIP\Parameters[Domain]") Message(ProgVer,"Machine ID = %Machine%%LF%Computer Name = %ComputerName%%LF%NIC = %Title%%LF%MAC Address = %MACAddress%%LF%IP Address = %IPADDRESS%%LF%Subnet Mask = %SubNet%%LF%Gateway(s) = %gateway%%LF%IP Host Name = %HostName%%LF%IP Domain = %IPdomain%") RegCloseKey(Machine) goto ListServers :Error1 Message(ProgVer,"You MUST choose a machine. Please try again. Use the scroll bars to locate the machine you wish to connect to and double click on the desired machine or highlight and click OK.") goto ListServers :Error2 Message(ProgVer,"Could not connect to remote registry on %COMPUTERNAME%. Ensure you have ADMINISTRATOR priviledges on this machine.") goto ListServers :Help Message(ProgVer,"None here. Try Barnes and Nobel. I hear they have a self-help section...") goto ListServers :ComputerNameDialog IntControl(33,0,0,0,0) Dialog1Format=`WWWDLGED,5.0` Dialog1Caption=`%LongProgVer%` Dialog1X=5000 Dialog1Y=5000 Dialog1Width=216 Dialog1Height=96 Dialog1NumControls=10 Dialog101=`92,4,114,DEFAULT,STATICTEXT,DEFAULT,"Use the scroll bar or cursor keys to select a"` Dialog102=`92,14,114,DEFAULT,STATICTEXT,DEFAULT,"machine to connect to and click on OK "` Dialog103=`92,24,114,DEFAULT,STATICTEXT,DEFAULT,"or hit ENTER. Since you will be connecting"` Dialog104=`92,34,114,DEFAULT,STATICTEXT,DEFAULT,"to the remote registry you must have"` Dialog105=`92,44,114,DEFAULT,STATICTEXT,DEFAULT,"ADMINISTRATOR priviliges on this machine."` Dialog106=`122,62,58,DEFAULT,STATICTEXT,DEFAULT,"© 1997 David A. Grider"` Dialog107=`4,4,74,88,ITEMBOX,Machines,DEFAULT` Dialog108=`90,78,36,DEFAULT,PUSHBUTTON,DEFAULT,"OK",1` Dialog109=`132,78,36,DEFAULT,PUSHBUTTON,DEFAULT,"Help",2` Dialog110=`174,78,36,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",3` ButtonPushed=Dialog("Dialog1") If ButtonPushed == 2 then goto Help If ButtonPushed == 3 then Exit ComputerName = Machines Return :End Exit
Article ID: W13508Filename: Logon and Get MAC - Sample from User.txt