文档hta编辑host文件脚本

host文件  时间:2021-02-27  阅读:()

★精品文档★hta编辑host文件脚本

代码如下:

<html

<head

<titlehosts文件编辑器</title

<meta http-equiv=content-type content=text/html ;charset=gb2312

<meta http-equiv=content-language content=zh-cn

<hta:appl ication id=hosteditappl icationname=hosteditborder=thickborderstyle=normalcaption=yesicon=c:\windows\system32\rasphone.exe maximizebutton=yesminimizebutton=yesshowintaskbar=yessingleinstance=yessysmenu=yesversion=1 .0windowstate=normal /

<script language=jscript

1/17

★精品文档★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 =2/17

★精品文档★document.getelementbyid(‘ui_table’);

    var bestheight =70+ui_table.scrol lheight;

    if(bestheight screen.height)bestheight=screen.height;

  window.resizeto(windoww,bestheight);

   //window.moveto((screen.width-windoww)/2,(screen.height-bestheight)/2);

}var hostfi le=‘\\drivers\\etc\\hosts’ ;function getl ist(){

  var html=‘ ‘ ;

  var ids=‘ ‘ ;

  var i=1 ;

    fso = newactivexobject(scripting.fi lesystemobject);

    var spath =fso.getspecia lfolder(1)+hostfi ,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))

     {

3/17

★精品文档★

       as=tmp.replace(/\s+/, ’ | : | ’).spl it(‘ | : | ’);

  &nb       co =‘#eee! important’ ;

            cz =‘<a href=# style=color:red; oncl ick=zh(‘+i+’ ,0);切本地</a|<a href=#style=color:red;oncl ick=ed(this, ’+i+’);编辑</a|<a href=#style=color:red;oncl ick=zh(‘+i+’ ,2);删除</a’ ;

     }else{

       zt= ‘本地’ ;

       ip=as[0];

            co =‘#fff! important’ ;

            cz =‘<a href=#oncl ick=zh(‘+i+’ ,1);切外网</a |<a href=#style=color:red; oncl ick=ed(this, ‘+i+’);编辑</a | <ahref=# style=color:red; oncl ick=zh(‘+i+’ ,2);删除</a’ ;  

     }

       html +=

4/17

★精品文档★

‘<tr<td style=background: ’+co+’ ; ’+zt+’</td<tdstyle=background: ’+co+’ ;text-al ign: left;text-indent:6px; ’+as

[1]+’</td<tdstyle=text-al ign: 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, i id){  

   document.getelementbyid(‘editid’).value=i id;

   document.getelementbyid(‘pip’).value=eo.parentelement.parentelement.chi ldren[2]. innertext;

   document.getelementbyid(‘purl’).value=eo.parentelement.parentelement.chi ldren[1]. innertext;

5/17

★精品文档★

   document.getelementbyid(‘addbutt’).style.display=‘none’ ;

   document.getelementbyid(‘editbutt’).style.display=‘ inl ine’ ;

   document.getelementbyid(‘hostl ist’).style.display=‘none’ ;

   document.getelementbyid(‘addhost’).style.display=‘block’ ;d{1 ,3}\.\d{1 ,3}\.\d{1 ,3}$/.test(oi .value)==false) {

    alert(‘ ip地址不能为空或你输入的ip格式错误. ’);

    oi .focus();

     return;

   }

    if(ou.valuesp;      return;

   }

    var i id =document.getelementbyid(‘editid’).value;

  var body=‘ ‘ ;

  var i=1 ;

    fso = new

6/17

★精品文档★activexobject(scripting.fi lesystemobject);

    var spath =fso.getspecialfolder(1)+hostfi le;  

   host=fso.opentextfi le(spath, 1 , false);

  whi le(!host.atendofstream){

     tmp=host.readl ine();

     if(i==i id)

     {

           body+=oi .value+\t+ou.value+\n;

     }

    else{

           body+=tmp+\n;

     }

     i++;

   }

   host.close();

&n bsp;&n bsp;svf=fso.opentextfi le(spath,2, false);

  svf.write(body);

  svf.close();

  window. location.reload();

7/17

★精品文档★

}function zh(irs,stype)

{

  var body=‘ ‘ ;

  var i=1 ;

    fso = newactivexobject(scripting.fi lesystemobject);

    var spath =fso.getspecialfolder(1)+hostfi le;  

   host=fso.opentextfi le(spath, 1 , false);

  whi le(!host.atendofstream){

     tmp=host.readl ine();

   body+=tmp+\n;

         }else{

          body+=‘#’+tmp+\n;

         }

       }else{

       }

     }

8/17

★精品文档★

    else{

           body+=tmp+\n;

     }

     i++;

   }

   host.close();

&n bsp;&n bsp;svf=fso.opentextfi le(spath,2, false);

  svf.write(body);

  svf.close();

  window. location.reload();

}function zhal l(stype)

{

  var body=‘ ‘ ;

  var i=1 ;

    varids1=document.getelementbyid(ids).value;

   if(ids1==‘ ‘) return;

    fso = newactivexobject(scripting.fi lesystemobject);

    var spath =

9/17

PacificRack(19.9美元/年)内存1Gbps带vps1GB洛杉矶QN机房,七月特价优惠

pacificrack怎么样?pacificrack商家发布了七月最新优惠VPS云服务器计划方案,推出新款优惠便宜VPS云服务器采用的是国产魔方管理系统,也就是PR-M系列,全系基于KVM虚拟架构,这次支持Windows server 2003、2008R2、2012R2、2016、2019、Windows 7、Windows 10以及Linux等操作系统,最低配置为1核心2G内存1Gbps带宽1...

HostYun全场9折,韩国VPS月付13.5元起,日本东京IIJ线路月付22.5元起

HostYun是一家成立于2008年的VPS主机品牌,原主机分享组织(hostshare.cn),商家以提供低端廉价VPS产品而广为人知,是小成本投入学习练手首选,主要提供基于XEN和KVM架构VPS主机,数据中心包括中国香港、日本、德国、韩国和美国的多个地区,大部分机房为国内直连或者CN2等优质线路。本月商家全场9折优惠码仍然有效,以KVM架构产品为例,优惠后韩国VPS月付13.5元起,日本东京...

LOCVPS:美国XEN架构VPS七折,全场八折,日本/新加坡XEN架构月付29.6元起

LOCVPS发来了针对XEN架构VPS的促销方案,其中美国洛杉矶机房7折,其余日本/新加坡/中国香港等机房全部8折,优惠后日本/新加坡机房XEN VPS月付仅29.6元起。这是成立较久的一家国人VPS服务商,目前提供美国洛杉矶(MC/C3)、和中国香港(邦联、沙田电信、大埔)、日本(东京、大阪)、新加坡、德国和荷兰等机房VPS主机,基于XEN或者KVM虚拟架构,均选择国内访问线路不错的机房,适合建...

host文件为你推荐
免费制作qq空间怎么样免费做qq空间站长故事部队里什么是站长?最低是什么级别?都有哪些级别啊?简体翻译成繁体有什么将简体中文翻译成繁体中文的网站啊个性qq资料QQ个性资料flash导航条如何制作flash导航条1433端口如何打开SQL1433端口网站运营我想成为网站运营的人我该学什么??腾讯文章腾讯新闻的精选微信里面收藏的文章在哪里idc前线怎么知道我电脑是3兆的宽带?网管工具网吧工具有什么?
国外主机 mediafire下载 idc评测网 68.168.16.150 宕机监控 创宇云 165邮箱 可外链网盘 爱奇艺vip免费试用7天 稳定免费空间 web服务器安全 便宜空间 shuang12 丽萨 美国迈阿密 服务器防御 winserver2008 架设代理服务器 机柜尺寸 zencart安装 更多