以下代码保存为vbs文件。
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("nslookup 220.181.108.88")
Do While oExec.Status = 0 ’=0 未执行完
WScript.Sleep 100
Loop
msgbox oExec.Status '=1 执行成功,=2 出错
msgbox oExec.StdErr.ReadAll()
msgbox oExec.StdOut.ReadAll()
如果不需要返回结果:
wscript.createObject("wscript.shell").Run("nslookup 220.181.108.88", 0, TRUE)
其中参数2是窗口状态,参数3=true 等待执行结果,=false 不等待直接返回
========================
ASP版(要求有执行WSCRIPT权限)
<pre>
<%
'response.write createObject("wscript.shell").Run("nslookup 220.181.108.88 >h:\111.txt", 0, TRUE)
Dim WshShell, oExec,i,ip
Set WshShell = CreateObject("WScript.Shell")
ip=request.querystring("ip")
if right(ip,1)*left(ip,1)<>clng(request.querystring("c")) then response.end
Set oExec = WshShell.Exec("nslookup " & ip)
i=0
Do While oExec.Status = 0
if i>1000000 then exit do
i=i+1
Loop
response.write oExec.StdErr.ReadAll()
response.write oExec.StdOut.ReadAll()
%>
</pre>