can't get nbtstat to work using shell script in WINXP

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top