代碼如下:
<hta:應用程序
id =“ mySampleHta”
字幕=“是”
滾動=“自動”
邊界=“無”
borderstyle =“靜態”
singleSinstance =“是”
最大化布頓=“否”
邊界=“否”
圖標=“ dxdiag.exe”>
<title> VPN連接程序hta版</title>
<樣式>
身體
{
字體大小:12;
背景:#Dadada;
左鍵:5;
}
輸入
{
寬度:50;
溢出:可見;
邊界:1PX固體燈光;
背景色:#cccccc;
光標:文字;
}
按鈕
{
邊界:1px固體灰色;
寬度:70;
左鍵:2;
光標:手;
字體大小:12;
過濾器:progid:dximagetransform.microsoft.gradient(startColorStr ='#eaeaff',endColorstr ='#618fff',gradientType ='0');
}
</style>
<身體>
<輸入id =“ id” size =“ 30” value =“ mjj”> </input> <br>
<輸入id =“ Pass” size =“ 30” value =“ mjj”> </input> <br>
<輸入id =“ ip” size =“ 50” value =“ VPN的ip”> </input> <br>
<button ID =“ ok” onclick = vbs:conn>鏈接</button>
<button ID =“ nok” onclick = vbs:dconn>斷開</button>
<button ID =“ ipshow” onclick = vbs:show>當前ip </button>
<button ID =“ vpnshow” onclick = vbs:vpnshow> vpn列表</button>
<button ID =“ vpnhelp” onclick = vbs:showhelp>幫助</button> <br>
<div ID =“ url”> </div>
</body>
<腳本語言=“ vbscript”>
設置oshell = createObject(“ wscript.shell”)
sub Window_onload
Window.Resizeto 450,380
Window.Moveto 300,300
複製
結束子
子副本
x(“ ip”)。值= me.clipboarddata.getdata(“ text”)
Settimeout“複製”,2000年
結束子
功能x(obj)
設置x = document.getElementById(obj)
結束功能
sub dconn
cmd = oshell.exec(“ rasdial /d”)。 stdout.readall()
x(“ url”)。 innerhtml = cmd
結束子
子顯示
x(“ url”)。 innerhtml =“ <br> <br> <iframe src = http://www.ip138.com/ip2city.asp> </iframe>”
結束子
子連接
tempfile =“ c:/tmp〜386”
如果findfile(tempfile)= false,則
writef tempfile,x(“ ip”)。值
x(“ url”)。 innerhtml =“創建pbk文件........好,連接中”
別的
writef tempfile,x(“ ip”)。值
x(“ url”)。 innerhtml =“ pbk file存在..........好,連接中”
如果結束
x(“ url”)。 innerhtml = oshell.exec(“ rasdial pvpn”&x(“ id”)。value&x&x(“ pass”)。value&“ value&” /phonebook:“&tempfile).stdout.readall()
結束子
sub vpnshow
set fso = createObject(“ scripting.filesystemobject”)
file =“ ip.txt”
設置txt = fso.opentextfile(文件)
如果不是txt.atendofstream,則'先確定還沒有到達結尾的位置
content = txt.readall'讀取整個文件的數據
lines =替換(content,vbcrlf,“ <br>”)'將文本內分行字符vbcrlf換成html換行標記“ <br>”
x(“ url”)。 innerhtml =線
如果結束
結束子
功能Findfile(str)
set fso = createObject(“ scripting.filesystemobject”)