• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >hta/htc > HTA编辑HOST文件的脚本

HTA编辑HOST文件的脚本

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了hta脚本,hta脚本之家,轴承hta040,hta,ntn轴承hta040等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
<HTML>
<HEAD>
<TITLE>HOSTS 文件编辑器</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-CN">
<HTA:APPLICATION ID="hostedit"
APPLICATIONNAME="hostedit"
BORDER="thick"
BORDERSTYLE="normal"
CAPTION="yes"
ICON="C:\WINDOWS\system32\rasphone.exe" 
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="normal" />
<script language="JScript">
window.onerror = function ()
{
    window.alert("程序发生了未知错误,当前窗口将被关闭!");
    window.close();
    return true;
}
var windowW=450;    //窗体宽
var windowH=200;    //窗体高
var canresize=false;//是否可以改变大小
var windowW2=windowW;//编辑时窗体宽
var windowH2=200;//编辑时窗体高
window.resizeTo(windowW,windowH);
//window.moveTo((screen.width-windowW)/2,(screen.height-windowH)/2);
window.onresize=function(){if(!canresize)window.resizeTo(windowW,windowH);}
function init()
{
    var ui_table = document.getElementById('UI_TABLE');
    var bestHeight = 70+ui_table.scrollHeight;
    if(bestHeight > screen.height) bestHeight = screen.height;
    window.resizeTo(windowW, bestHeight);
    //window.moveTo((screen.width-windowW)/2,(screen.height-bestHeight)/2);
}
var hostfile = '\\drivers\\etc\\hosts';
function getlist(){
    var html='';
    var ids='';
    var i=1;
    FSO = new ActiveXObject("Scripting.FileSystemObject");
    var spath = FSO.GetSpecialFolder(1)+hostfile;
    host = FSO.OpenTextFile(spath, 1, false);
    while(!host.AtEndOfStream){
         tmp = host.ReadLine();
         if(/^#?\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s+([a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+(\.(com|net|org|edu|info|biz|cc|tv|gov|mobi|name|cn|en|us|hk|tw))+)$/.test(tmp))
         {
        as=tmp.replace(/\s+/,'|:|').split('|:|');
        ids+='['+i+'],';
        if(/^\#/.test(as[0])){
            zt = '外网';
            ip = as[0].replace(/^\#/,'');
            co = '#eee!important';
            cz = '<a href="#" style="color:red;" onclick="zh('+i+',0);">切本地</a> | <a href="#" style="color:red;" onclick="ed(this,'+i+');">编辑</a> | <a href="#" style="color:red;" onclick="zh('+i+',2);">删除</a>';

        }else{
            zt = '本地';
            ip = as[0];
            co = '#fff!important';
            cz = '<a href="#" onclick="zh('+i+',1);">切外网</a> | <a href="#" style="color:red;" onclick="ed(this, '+i+');">编辑</a> | <a href="#" style="color:red;" onclick="zh('+i+',2);">删除</a>';    
        }

            html += '<tr><td style="background:'+co+';">'+zt+'</td><td style="background:'+co+';text-align:left;text-indent:6px;">'+as[1]+'</td><td style="text-align:left;text-indent:6px;background:'+co+';">'+ip+'</td><td style="background:'+co+';">'+cz+'</td></tr>';
        }
        i++;
    }
    var o=document.getElementById('ids');
    o.value=ids;
    host.Close();
    return html;
}

function ed(eo, iId){    
    document.getElementById('editId').value=iId;
    document.getElementById('pIP').value=eo.parentElement.parentElement.children[2].innerText;
    document.getElementById('pURL').value=eo.parentElement.parentElement.children[1].innerText;
    document.getElementById('addButt').style.display='none';
    document.getElementById('editButt').style.display='inline';
    document.getElementById('HostList').style.display='none';
    document.getElementById('addHost').style.display='block';
    window.resizeTo(windowW2,windowH2);
}

function edits(sIp, sUrl){
    var oi=document.getElementById(sIp);
    var ou=document.getElementById(sUrl);
    if(oi.value=='' || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(oi.value)==false) {
        alert('IP地址不能为空或你输入的IP格式错误.');
        oi.focus();
        return;
    }
    if(ou.value=='' || /^[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+(\.(com|net|org|edu|info|biz|cc|tv|gov|mobi|name|cn|en|us|hk|tw))+$/.test(ou.value)==false) {
        alert('域名不能为空或你输入的域名格式错误.');
        ou.focus();
        return;
    }
    var iId = document.getElementById('editId').value;
    var body='';
    var i=1;
    FSO = new ActiveXObject("Scripting.FileSystemObject");
    var spath = FSO.GetSpecialFolder(1)+hostfile;    
    host = FSO.OpenTextFile(spath, 1, false);
    while(!host.AtEndOfStream){
        tmp = host.ReadLine();
        if(i==iId)
        {
            body+=oi.value+"\t"+ou.value+"\n";
        } <

您可能想查找下面的文章:

  • HTA编辑HOST文件的脚本
  • hta查看磁盘空间的脚本
  • 用vbs在 HTA 内对脚本进行编码的方法

相关文章

  • 关键字排名(Keyword Ranking)
  • XMLDOM下载者生成器代码(xmldown.hta)
  • hta实现的定时重启或关闭计算机的小工具
  • 用hta实现的远程桌面连接脚本
  • 从 HTA 中启动应用程序
  • HTA编辑HOST文件的脚本
  • A notepad made in HTA(hta实现的记事本)
  • hta实现的笨狼XSLT练习器
  • 锁定行头和列头的表格组件
  • code collection v0.44 hta

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • HTML Component(HTC) 小应用
    • 无间断滚动效果 htc
    • hta实现的笨狼树状节点查看器
    • 适用于hta的Sleep函数
    • 锁定行头和列头的表格组件
    • 网易手机图片自由下载器(hta)
    • XMLHttps
    • HTC基础知识
    • 用vbs如何确定在 HTA 中选择了哪些文本?
    • hta实现的二进制文件转换为文本

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有