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

ZJI-全场八折优惠,香港服务器 600元起,还有日本/美国/韩国服务器

月付/年付优惠码:zji  下物理服务器/VDS/虚拟主机空间订单八折终身优惠(长期有效)一、ZJI官网点击直达ZJI官方网站二、特惠香港日本服务器香港大埔:http://hkdb.speedtest.zji.net/香港葵湾:http://hkkw.speedtest.zji.net/日本大阪:http://jpsk.speedtest.zji.net/日本大阪一型 ...

RAKsmart:美国洛杉矶独服,E3处理器/16G/1TB,$76.77/月;美国/香港/日本/韩国站群服务器,自带5+253个IPv4

RAKsmart怎么样?RAKsmart机房即日起开始针对洛杉矶机房的独立服务器进行特别促销活动:低至$76.77/月,最低100Mbps带宽,最高10Gbps带宽,优化线路,不限制流量,具体包括有:常规服务器、站群服务器、10G大带宽服务器、整机机柜托管。活动截止6月30日结束。RAKsmart,美国华人老牌机房,专注于圣何塞服务器,有VPS、独立服务器等。支持PayPal、支付宝付款。点击直达...

CloudCone闪购优惠洛杉矶MC机房VPS月$1.99 便宜可随意删除重开

CloudCone商家我们很多喜欢低价便宜VPS主机的肯定是熟悉的,个人不是特别喜欢他。因为我之前测试过几次,开通的机器IP都是不通的,需要删除且开通好几次才能得到一个可用的IP地址。当然他们家的优势也是有的,就是价格确实便宜,而且还支持删除重新开通,而且机房只有一个洛杉矶MC。实话,如果他们家能多几个机房,保持现在的特点,还是有很多市场的。CloudCone是来自美国的主机销售商,成立于2017...

host文件为你推荐
淘宝客推广淘宝客推广有用吗?站长故事爱迪生的故事伪静态什么是伪静态伪静态有何作用arm开发板ARM开发板和树莓派有什么区别arm开发板单片机开发板与ARM开发板有什么不同?安卓应用平台有没有什么安卓游戏都能找到的应用商店或者游戏中心申请证书手机申请证书qq怎么发邮件qq怎么发文件和邮件雅虎天盾有没有用用雅虎天盾的啊?idc前线怎么知道我电脑是3兆的宽带?
jsp虚拟空间 上海虚拟主机 阿里云邮箱登陆首页 adman bbr 香港机房托管 圣诞节促销 ibox官网 怎么测试下载速度 seednet 789电视网 免费防火墙 静态空间 cdn加速原理 亚马逊香港官网 网络空间租赁 天翼云盘 上海服务器 新加坡空间 西安主机 更多