ASP获取远程的计算机名

来源:互联网 发布:云计算主题基金 编辑:程序博客网 时间:2024/05/01 04:20

strIP = Request.ServerVariables("REMOTE_ADDR") 
strHost = Request.ServerVariables("REMOTE_HOST") 

Set net = Server.CreateObject("wscript.network") 
Set sh = Server.CreateObject("wscript.shell") 
sh.run "%comspec% /c nbtstat -A " & strIP & " 〉 d:/wwwtemp/" & strIP & ".txt",0,true 
sh.run "%comspec% /c ping -a " & strIP & " 〉 d:/wwwtemp/" & strIP & "ping.txt",0,true 
Set sh = nothing 

'分析ping命令结果获取计算机名 
Function GetComputerName(strIP) 
set fso=CreateObject("scripting.filesystemobject") 
set ts=fso.opentextfile("d:/wwwtemp/" & strIP & "ping.txt") 
computername=null 
do while not ts.AtEndOfStream 
data = ucase(trim(ts.readline)) 
if instr(data,"[") then 
computername=trim(split(data,"[")(0)) 
computername=trim(replace(computername,"PINGING","")) 
exit do 
end if 
loop 
GetComputerName=computername 
End Function 

'分析nbtstat命令结果获取MAC地址 
Function GetMACAddress(strIP) 
Set fso = createobject("scripting.filesystemobject") 
Set ts = fso.opentextfile("d:/wwwtemp/" & strIP & ".txt") 
macaddress = null 
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 
GetMACAddress = macaddress 
End Function  

 

<script type="text/javascript"><!--google_ad_client = "pub-4717125974896180";/* 728x90, 创建于 09-7-17 */google_ad_slot = "3536088218";google_ad_width = 728;google_ad_height = 90;// --></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>