vpn连接程序hta版实现代码(修改)

代码如下:

<HTA:APPLICATION
ID="MySampleHTA"
Caption="yes"
SCROLL="auto"
border="none"
borderStyle="static"
SINGLEINSTANCE="yes"
maximizebutton="no"
BORDER="no"
icon="dxdiag.exe">

<title>vpn 连接程序 hta版</title>
<style>
body
{
font-size:12;
BACKGROUND: #DADADA;
margin-left:5;

}

input
{
width:50;
overflow:visible;
border:1px solid lightblue;
background-color:#cccccc;
cursor:text;
}
button
{
border:1px solid gray;
width:70;
margin-left:2;
cursor:hand;
font-size:12;
filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#eaeaff', endColorStr='#618fff', gradientType='0');
}

</style>
<body>
<input id="id" size="30" value="mjj"></input><br>
<input id="pass" size="30" value="mjj"></input><br>
<input 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>

<SCRIPT LANGUAGE="VBScript">
Set oShell = CreateObject("WScript.Shell")

Sub Window_onLoad
window.resizeTo 450,380
window.moveTo 300, 300
copy
End Sub

Sub copy
x("ip").value=me.clipboarddata.getdata("Text")
setTimeout "copy", 2000
End Sub

Function x(obj)
Set x=document.getElementById(obj)
End function

Sub dconn
cmd=oShell.exec("rasdial /d").StdOut.ReadAll()
x("url").innerHTML=cmd

End Sub

Sub show
x("url").innerHTML= "<br><br><iframe src=http://www.ip138.com/ip2city.asp></iframe>"
End Sub

Sub conn
tempfile="c:\tmp~386"
If Findfile(tempfile) = false Then
writef tempfile,x("ip").value
x("url").innerHTML ="Create pbk file ........ok,连接中"
Else
writef tempfile,x("ip").value
x("url").innerHTML ="pbk file 存在........ok,连接中"
End If

x("url").innerHTML= oShell.exec("rasdial pvpn "&x("id").value&" "&x("pass").value&" /PHONEBOOK:"&tempfile).StdOut.ReadAll()

End Sub

Sub vpnshow
Set FSO = CreateObject("Scripting.FileSystemObject")
File = "ip.txt"
Set txt = fso.OpenTextFile(File)
If Not txt.atEndOfStream Then '先确定还没有到达结尾的位置
Content = txt.ReadAll '读取整个文件的数据
Lines = Replace(Content, vbCrlf, "<br>") '将文本内分行字符vbCrlf换成HTML换行标记"<br>"
x("url").innerHTML= Lines
End If

End Sub

Function Findfile(str)
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(str) Then
findfile=true
Else
findfile=false
End If
End Function

Function writef(pbk_file,ip)
Set FSO = CreateObject("Scripting.FileSystemObject")
with fso.opentextfile(pbk_file,2,true)
.writeline "[pvpn]"
.writeline "Encoding=1"
.writeline "Type=2"
.writeline "AutoLogon=0"
.writeline "UseRasCredentials=1"
.writeline "DialParamsUID=546750"
.writeline "Guid=76C5D8FF120C6A4F8E63F0B1E5D74AD4"
.writeline "BaseProtocol=1"
.writeline "VpnStrategy=2"
.writeline "ExcludedProtocols=0"
.writeline "LcpExtensions=1"
.writeline "DataEncryption=8"
.writeline "SwCompression=1"
.writeline "NegotiateMultilinkAlways=0"
.writeline "SkipNwcWarning=0"
.writeline "SkipDownLevelDialog=0"
.writeline "SkipDoubleDialDialog=0"
.writeline "DialMode=1"
.writeline "DialPercent=75"
.writeline "DialSeconds=120"
.writeline "HangUpPercent=10"
.writeline "HangUpSeconds=120"
.writeline "OverridePref=15"
.writeline "RedialAttempts=3"
.writeline "RedialSeconds=60"
.writeline "IdleDisconnectSeconds=0"
.writeline "RedialOnLinkFailure=0"
.writeline "CallbackMode=0"
.writeline "CustomDialDll="
.writeline "CustomDialFunc="
.writeline "CustomRasDialDll="
.writeline "AuthenticateServer=0"
.writeline "ShareMsFilePrint=1"
.writeline "BindMsNetClient=1"
.writeline "SharedPhoneNumbers=0"
.writeline "GlobalDeviceSettings=0"
.writeline "PrerequisiteEntry="
.writeline "PrerequisitePbk="
.writeline "PreferredPort=VPN4-0"
.writeline "PreferredDevice=WAN Miniport (L2TP)"
.writeline "PreferredBps=0"
.writeline "PreferredHwFlow=1"
.writeline "PreferredProtocol=1"
.writeline "PreferredCompression=1"
.writeline "PreferredSpeaker=1"
.writeline "PreferredMdmProtocol=0"
.writeline "PreviewUserPw=1"
.writeline "PreviewDomain=0"
.writeline "PreviewPhoneNumber=0"
.writeline "ShowDialingProgress=1"
.writeline "ShowMonitorIconInTaskBar=1"
.writeline "CustomAuthKey=-1"
.writeline "AuthRestrictions=608"
.writeline "TypicalAuth=2"
.writeline "IpPrioritizeRemote=1"
.writeline "IpHeaderCompression=0"
.writeline "IpAddress=0.0.0.0"
.writeline "IpDnsAddress=0.0.0.0"
.writeline "IpDns2Address=0.0.0.0"
.writeline "IpWinsAddress=0.0.0.0"
.writeline "IpWins2Address=0.0.0.0"
.writeline "IpAssign=1"
.writeline "IpNameAssign=1"
.writeline "IpFrameSize=1006"
.writeline "IpDnsFlags=0"
.writeline "IpNBTFlags=1"
.writeline "TcpWindowSize=0"
.writeline "UseFlags=0"
.writeline "IpSecFlags=0"
.writeline "IpDnsSuffix="
.writeline ""
.writeline "NETCOMPONENTS="
.writeline "ms_server=1"
.writeline "ms_msclient=1"
.writeline "ms_psched=1"
.writeline ""
.writeline "MEDIA=rastapi"
.writeline "Port=VPN4-0"
.writeline "Device=WAN Miniport (L2TP)"
.writeline ""
.writeline "DEVICE=vpn"
.writeline "PhoneNumber="&x("ip").value
.writeline "AreaCode="
.writeline "CountryCode=1"
.writeline "CountryID=1"
.writeline "UseDialingRules=0"
.writeline "Comment="
.writeline "LastSelectedPhone=0"
.writeline "PromoteAlternates=0"
.writeline "TryNextAlternateOnFail=1"
.writeline ""

.close
End with
Set fso = Nothing
End Function

sub showHelp
msg = " 在同目录下建立ip.txt" & vbcrlf
msg = msg & "------------------------------------------------" & vbcrlf
msg = msg & " ip.txt里是vpn的ip列表,一行一个,可以在每行里加说明" & vbcrlf
msg = msg & "复制IP会自动粘贴到ip框里,是否成功的话,请看ip显示:" & vbcrlf

alert msg
end sub
</SCRIPT>

(0)

相关推荐

  • vpn连接程序hta版实现代码(修改)

    复制代码 代码如下: <HTA:APPLICATION ID="MySampleHTA" Caption="yes" SCROLL="auto" border="none" borderStyle="static" SINGLEINSTANCE="yes" maximizebutton="no" BORDER="no" icon="

  • c#实现windows远程桌面连接程序代码

    使用winform制作windows远程桌面连接程序,windows自带了远程桌面连接,我们需要将远程桌面连接集成 到自己的winform程序,并实现管理远程主机的配置. 远程桌面核心类库 windows系统自带了远程桌面activex dll,目录: c:\Windows\System32\mstscax.dll 此类库无法使用c#直接调用,介绍一个工具AxImp.exe AxImp.exe https://msdn.microsoft.com/zh-cn/library/8ccdh774(V

  • asp连接SQL和Access数据代码(asp里的随机函数)

    asp连接sql 第一种写法: 复制代码 代码如下: MM_conn_STRING = "Driver={SQL Server};server=(local);uid=sa;pwd=;database=infs;" Set conn = Server.Createobject("ADODB.Connection") conn.open MM_conn_STRING SET RS=SERVER.CreateObject("ADOBD.recordset&qu

  • php 批量替换程序的具体实现代码

    代码如下: 复制代码 代码如下: <?php/***************************************************************************batch-replace, v1.1***************************************************************************file: batch-replace_utf8.phpfunctionality: 本程序可以扫描指定目录的所有文

  • Java连接postgresql数据库的示例代码

    本文介绍了Java连接postgresql数据库的示例代码,分享给大家,具体如下: 1.下载驱动jar 下载地址:https://jdbc.postgresql.org/download.html 2.导入jar包 新建lib文件夹,将下载的jar驱动包拖到文件夹中. 将jar驱动包添加到Libraries 3.程序代码如下:HelloWorld.java package test; import java.sql.Connection; import java.sql.DriverManage

  • C++简单QQ程序服务器端的实现代码

    本文实例为大家分享了C++简单QQ程序服务器端的实现代码,供大家参考,具体内容如下 // ServerDlg.cpp : implementation file // #include "StdAfx.h" #include "Server.h" #include "ServerDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] =

  • 微信小程序点击控件修改样式实例详解

    微信小程序点击控件修改样式实例详解 现在要在微信小程序中实现点击控件修改样式,如下: 微信小程序中不支持直接操作dom,要实现这种效果,我们需要通过设置data,然后利用数据和界面的双向绑定来实现它. 第一步:在wxss中定义被点击和未被点击的样式,如下: .service_selection .is_checked{ border: 1px solid #FE0002 ; color: #FE0002 ; background: #fff; } .service_selection .norm

  • 微信小程序基于slider组件动态修改标签透明度的方法示例

    本文实例讲述了微信小程序基于slider组件动态修改标签透明度的方法.分享给大家供大家参考,具体如下: 1.效果展示 2.关键代码 index.wxml <view class="img" style="opacity:{{imgOpacity}}"></view> <slider min="0" max="1" step="0.1" show-value value=&quo

  • 微信小程序实现点击按钮修改字体颜色功能【附demo源码下载】

    本文实例讲述了微信小程序实现点击按钮修改字体颜色功能.分享给大家供大家参考,具体如下: 1.效果展示 2.关键代码 index.wxml文件 <view class="view" style="color:{{color}}">我是view标签</view> <view style="display:flex;"> <block wx:for="{{colorArray}}" wx:k

  • K均值聚类算法的Java版实现代码示例

    1.简介 K均值聚类算法是先随机选取K个对象作为初始的聚类中心.然后计算每个对象与各个种子聚类中心之间的距离,把每个对象分配给距离它最近的聚类中心.聚类中心以及分配给它们的对象就代表一个聚类.一旦全部对象都被分配了,每个聚类的聚类中心会根据聚类中现有的对象被重新计算.这个过程将不断重复直到满足某个终止条件.终止条件可以是没有(或最小数目)对象被重新分配给不同的聚类,没有(或最小数目)聚类中心再发生变化,误差平方和局部最小. 2.什么是聚类 聚类是一个将数据集中在某些方面相似的数据成员进行分类组织

随机推荐