文档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

快快云:香港沙田CN2/美国Cera大宽带/日本CN2,三网直连CN2 GIA云服务器和独立服务器

快快云怎么样?快快云是一家成立于2021年的主机服务商,致力于为用户提供高性价比稳定快速的主机托管服务,快快云目前提供有香港云服务器、美国云服务器、日本云服务器、香港独立服务器、美国独立服务器,日本独立服务器。快快云专注为个人开发者用户,中小型,大型企业用户提供一站式核心网络云端服务部署,促使用户云端部署化简为零,轻松快捷运用云计算!多年云计算领域服务经验,遍布亚太地区的海量节点为业务推进提供强大...

Hostiger发布哥伦布日提供VPS主机首月七折优惠 月费2.79美元

Hostiger商家我们可能以前也是有见过的,以前他们的域名是Hostigger,后来进行微调后包装成现在的。而且推出Columbus Day哥伦布日优惠活动,提供全场的VPS主机首月7折月付2.79美元起的优惠。这里我们普及一下基础知识,Columbus Day ,即为每年10月12日,是一些美洲国家的节日,纪念克里斯托弗·哥伦布在北美登陆,为美国的联邦假日。Hostiger 商家是一个成立于2...

杭州王小玉网-美国CERA 2核8G内存19.9元/月,香港,日本E3/16G/20M CN2带宽150元/月,美国宿主机1500元,国内宿主机1200元

官方网站:点击访问王小玉网络官网活动方案:买美国云服务器就选MF.0220.CN 实力 强 强 强!!!杭州王小玉网络 旗下 魔方资源池 “我亏本你引流活动 ” mf.0220.CNCPU型号内存硬盘美国CERA机房 E5 2696v2 2核心8G30G总硬盘1个独立IP19.9元/月 续费同价mf.0220.CN 购买湖北100G防御 E5 2690v2 4核心4G...

host文件为你推荐
免费开通黄钻能免费开通黄钻吗??9flash在“属性”对话框中的“Move”后面的框中输入Flash动画文件的绝对路径及文件名,这句话怎么操作?idc前线穿越火线河北的服务器好卡 有人知道怎么回事嘛 知道的速回bluestackbluestacks安卓模拟器有什么用虚拟机软件下载谁有好用的虚拟机软件?网站优化方案网站优化方案如何写?cisco防火墙思科防火墙asa5505路由配置是什么?王炳坤南北小年为何不同日怎么把网页的字变大如何将页面的字变大nokia最新手机诺基亚手机最新款2017怎么样
新网域名解析 sugarhosts 国外服务器网站 shopex空间 512au 建立邮箱 稳定免费空间 美国在线代理服务器 香港新世界中心 丽萨 华为云建站 php服务器 免费个人网页 netvigator tracker服务器 2016黑色星期五 服务器是什么意思 带宽测速 美国西雅图独立 木马检测 更多