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
如何使用ASP獲取遠端的計算機名
language vbscript codepage 936 strip request.servervariables remote addr strhost request.servervariables remote host set net server.createobject wscri...
獲取計算機的IP位址和計算機名
利用winsock函式獲取主機名和ip位址非常簡單,可以有很多種方法,最簡單的只需通過兩個函式gethostname和gethostbyname可以解決。1 函式gethostname 該函式原型為 int gethostname char name,int namelen 其中,引數name是乙個...
通過計算機名 獲取 IP
注意 紅色部分可能根據需要進行修改 yourtestpcname 即是你需要測試的計算機名稱 紅色的數字部分是由跟環境的ip位址有關聯 複製以下 到bat檔案即可。echo off set pcname color red yourtestpcname color ping pcname 4 ech...