R
Roylei
I found a script on this site to get the users MAC address using
nbtstat. Here's the script:
Function GetMACAddress(ByVal strIP) As String
Dim net = CreateObject("wscript.network")
Dim sh = Server.CreateObject("wscript.shell")
sh.run("%comspec% /c nbtstat -A " & strIP & " >
c:\inetpub\wwwroot\test\mac\" & strIP & ".txt", 0, True)
sh = Nothing
Dim fso = CreateObject("scripting.filesystemobject")
Dim ts = fso.opentextfile("c:\inetpub\wwwroot\test\mac\" &
strIP & ".txt")
Dim MacAddress As String
Dim Data As String
Do While Not ts.AtEndOfStream
Data = UCase(Trim(ts.readline))
If InStr(Data, "MAC ADDRESS") Then
MacAddress = Trim(Split(Data, "=")(1))
Exit Do
End If
Loop
ts.close()
ts = Nothing
fso.deletefile("c:\inetpub\wwwroot\test\mac\" & strIP &
".txt")
fso = Nothing
GetMACAddress = MacAddress
End Function
My problem is that the file created is 0kb. I can't figure out why
the script doesn't run properly. I tried replacing the nbtstat
command with a dir command, and that works fine. Any ideas?It only
happens in WINXP.The script works in win2000.Is there any permission
issue?
Thanks!
nbtstat. Here's the script:
Function GetMACAddress(ByVal strIP) As String
Dim net = CreateObject("wscript.network")
Dim sh = Server.CreateObject("wscript.shell")
sh.run("%comspec% /c nbtstat -A " & strIP & " >
c:\inetpub\wwwroot\test\mac\" & strIP & ".txt", 0, True)
sh = Nothing
Dim fso = CreateObject("scripting.filesystemobject")
Dim ts = fso.opentextfile("c:\inetpub\wwwroot\test\mac\" &
strIP & ".txt")
Dim MacAddress As String
Dim Data As String
Do While Not ts.AtEndOfStream
Data = UCase(Trim(ts.readline))
If InStr(Data, "MAC ADDRESS") Then
MacAddress = Trim(Split(Data, "=")(1))
Exit Do
End If
Loop
ts.close()
ts = Nothing
fso.deletefile("c:\inetpub\wwwroot\test\mac\" & strIP &
".txt")
fso = Nothing
GetMACAddress = MacAddress
End Function
My problem is that the file created is 0kb. I can't figure out why
the script doesn't run properly. I tried replacing the nbtstat
command with a dir command, and that works fine. Any ideas?It only
happens in WINXP.The script works in win2000.Is there any permission
issue?
Thanks!