bat实现往hosts文件追加内容

[

](https://www.googleadservices.com/pagead/aclk?sa=L&ai=C-zm_x7J0Ys2WIMfT2ATH-KQo4Ny0-2m09Y_K-w-jlfT9CBABIOHa4wVgnQGgAeqPj4YDyAEJqQLEjEFM-xGEPqgDAcgDywSqBPoBT9A1nrzGDL-U6yXWRV4co6keJwm80gkCdMeeuaq4nu01YhRWGFXTMd3Z-Ki3btnTANbw8EbAzRpozDzOR3r6BGcI98mtUz_Z8sLdk-M-TlcqK7ur17IvJZYMdnm_PI3d2NaSZpIO4nhP-VNOFt01RAaL_mLVB8qfqJO_0OSEZ_FYjcpmGDNL_1uARwzUHkFioqU_4K-aZlZqPM6ecsN7VvHOxRh1xetN3usWj21_pmvZnilxbRLkP80sw1ACdx_NmRIg-faErYEgKdtCbHZTgD4bdV_M365UOvdwwKyHMlroDnbjaPfEsDU4VslqgENZ41QWEJ_0lAf7HMAE44v8wP0DoAYugAepp4yjAagHjs4bqAeT2BuoB-6WsQKoB_6esQKoB6SjsQKoB9XJG6gHpr4bqAfz0RuoB5bYG6gHqpuxAqgH35-xAtgHANIIBwiAYRABGB-xCXPK57-tiWjagAoBmAsByAsBgAwBuAwBuBOIJ9gTDYgUAdAVAfgWAYAXAQ&ae=1&num=1&cid=CAASJeRoh62J1dfFWb4AMYGk-fwzK14M3lg6un17s09N3FGjQWB4egk&sig=AOD64_2CpvJDKV0J_Z_Kn9KsaUQx1jkivA&client=ca-pub-9051032955849697&nb=9&adurl=https://cloud.tencent.com/act/new%3FfromSource%3Dgwzcw.6321087.6321087.6321087%26utm_medium%3Dcpc%26utm_id%3Dgwzcw.6321087.6321087.6321087%26gclid%3DEAIaIQobChMIjZbU55LK9wIVxymWCh1HPAkFEAEYASAAEgIXgPD_BwE)

4核8G云服务器,388元/年

企业新用户专享2核4G云服务器,首年仅需168元

[](https://www.googleadservices.com/pagead/aclk?sa=L&ai=C-zm_x7J0Ys2WIMfT2ATH-KQo4Ny0-2m09Y_K-w-jlfT9CBABIOHa4wVgnQGgAeqPj4YDyAEJqQLEjEFM-xGEPqgDAcgDywSqBPoBT9A1nrzGDL-U6yXWRV4co6keJwm80gkCdMeeuaq4nu01YhRWGFXTMd3Z-Ki3btnTANbw8EbAzRpozDzOR3r6BGcI98mtUz_Z8sLdk-M-TlcqK7ur17IvJZYMdnm_PI3d2NaSZpIO4nhP-VNOFt01RAaL_mLVB8qfqJO_0OSEZ_FYjcpmGDNL_1uARwzUHkFioqU_4K-aZlZqPM6ecsN7VvHOxRh1xetN3usWj21_pmvZnilxbRLkP80sw1ACdx_NmRIg-faErYEgKdtCbHZTgD4bdV_M365UOvdwwKyHMlroDnbjaPfEsDU4VslqgENZ41QWEJ_0lAf7HMAE44v8wP0DoAYugAepp4yjAagHjs4bqAeT2BuoB-6WsQKoB_6esQKoB6SjsQKoB9XJG6gHpr4bqAfz0RuoB5bYG6gHqpuxAqgH35-xAtgHANIIBwiAYRABGB-xCXPK57-tiWjagAoBmAsByAsBgAwBuAwBuBOIJ9gTDYgUAdAVAfgWAYAXAQ&ae=1&num=1&cid=CAASJeRoh62J1dfFWb4AMYGk-fwzK14M3lg6un17s09N3FGjQWB4egk&sig=AOD64_2CpvJDKV0J_Z_Kn9KsaUQx1jkivA&client=ca-pub-9051032955849697&nb=8&adurl=https://cloud.tencent.com/act/new%3FfromSource%3Dgwzcw.6321087.6321087.6321087%26utm_medium%3Dcpc%26utm_id%3Dgwzcw.6321087.6321087.6321087%26gclid%3DEAIaIQobChMIjZbU55LK9wIVxymWCh1HPAkFEAEYASAAEgIXgPD_BwE)

腾讯云

打开

[

](https://www.googleadservices.com/pagead/aclk?sa=L&ai=C-zm_x7J0Ys2WIMfT2ATH-KQo4Ny0-2m09Y_K-w-jlfT9CBABIOHa4wVgnQGgAeqPj4YDyAEJqQLEjEFM-xGEPqgDAcgDywSqBPoBT9A1nrzGDL-U6yXWRV4co6keJwm80gkCdMeeuaq4nu01YhRWGFXTMd3Z-Ki3btnTANbw8EbAzRpozDzOR3r6BGcI98mtUz_Z8sLdk-M-TlcqK7ur17IvJZYMdnm_PI3d2NaSZpIO4nhP-VNOFt01RAaL_mLVB8qfqJO_0OSEZ_FYjcpmGDNL_1uARwzUHkFioqU_4K-aZlZqPM6ecsN7VvHOxRh1xetN3usWj21_pmvZnilxbRLkP80sw1ACdx_NmRIg-faErYEgKdtCbHZTgD4bdV_M365UOvdwwKyHMlroDnbjaPfEsDU4VslqgENZ41QWEJ_0lAf7HMAE44v8wP0DoAYugAepp4yjAagHjs4bqAeT2BuoB-6WsQKoB_6esQKoB6SjsQKoB9XJG6gHpr4bqAfz0RuoB5bYG6gHqpuxAqgH35-xAtgHANIIBwiAYRABGB-xCXPK57-tiWjagAoBmAsByAsBgAwBuAwBuBOIJ9gTDYgUAdAVAfgWAYAXAQ&ae=1&num=1&cid=CAASJeRoh62J1dfFWb4AMYGk-fwzK14M3lg6un17s09N3FGjQWB4egk&sig=AOD64_2CpvJDKV0J_Z_Kn9KsaUQx1jkivA&client=ca-pub-9051032955849697&nb=8&adurl=https://cloud.tencent.com/act/new%3FfromSource%3Dgwzcw.6321087.6321087.6321087%26utm_medium%3Dcpc%26utm_id%3Dgwzcw.6321087.6321087.6321087%26gclid%3DEAIaIQobChMIjZbU55LK9wIVxymWCh1HPAkFEAEYASAAEgIXgPD_BwE)

做个笔记。

  1. @echo off
  2. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3. :::::::::::::::::::::::ADMIN POWER(start)::::::::::::::::::::::
  4. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5. nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  6. if '%errorlevel%' NEQ '0' (
  7. goto UACPrompt
  8. ) else ( goto gotAdmin )
  9. :UACPrompt
  10. echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  11. echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
  12. "%temp%\getadmin.vbs"
  13. exit /B
  14. :gotAdmin
  15. if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
  16. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  17. ::::::::::::::::::::::::ADMIN POWER(end):::::::::::::::::::::::
  18. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  19. set a=192.168.13.11 chenglee-001
  20. set file=C:\Windows\System32\drivers\etc\hosts
  21. ::(echo.) >> %file%
  22. (echo %a%) >> %file%
  23. echo 写入成功...5秒后退出窗口
  24. choice /t 5 /d y /n >nul
  25. ::pause
  26. exit

第一块获取管理员admin权限, 第二块实现写入, 去掉不相关空格。

[

](https://www.googleadservices.com/pagead/aclk?sa=L&ai=Cnpx3x7J0YpiVIM7m2AT6uaqwBeDctPtptPWPyvsPo5X0_QgQASDh2uMFYJ0BoAHqj4-GA8gBCakCxIxBTPsRhD6oAwHIA8sEqgT5AU_Q2iHdPPa4PKltH3Ud7k0t0FlqwFRjgg03QxcO1FccX94SjArnGps5w-87A8i5il0rmWXHYRcWOqVnQXs1sfaXzR2DwGuo5twD8SSuAnbafT24hHhDxjzH2R9RyyoMVFNP5wt7ezv8Lq18Ayn-zz3WefXLAdD6Y3FCJDrZQciWel18k5egnTkNW3LMtpsJzgiju1H5FnlHD3gkHl3x6IO_yfGzdmUvH_3H86MiijfK7YsNI4gHAOiaaVBQyypgsbqreeQovKi0WiS5azByZbx2hwT1u_HE4kQLw0HguhzT7ZYFf1TNl161W56fJyUQeSofYNSt-kWmOsAE44v8wP0DoAYugAepp4yjAagHjs4bqAeT2BuoB-6WsQKoB_6esQKoB6SjsQKoB9XJG6gHpr4bqAfz0RuoB5bYG6gHqpuxAqgH35-xAtgHANIIBwiAYRABGB-xCXPK57-tiWjagAoBmAsByAsBgAwBuAwBuBOIJ9gTDYgUAdAVAfgWAYAXAQ&ae=1&num=1&cid=CAASJeRo02vTqF9LgNFyxSPFdWReZVC_rdUCD88BoP4yoWENeONm0kE&sig=AOD64_0s6SSqx_Pvtue4vVcNvMAJZL35sg&client=ca-pub-9051032955849697&nb=9&adurl=https://cloud.tencent.com/act/new%3FfromSource%3Dgwzcw.6321087.6321087.6321087%26utm_medium%3Dcpc%26utm_id%3Dgwzcw.6321087.6321087.6321087%26gclid%3DEAIaIQobChMI2JTU55LK9wIVTjOWCh36nApWEAEYASAAEgISk_D_BwE)

4核8G云服务器,388元/年

企业新用户专享2核4G云服务器,首年仅需168元

[](https://www.googleadservices.com/pagead/aclk?sa=L&ai=Cnpx3x7J0YpiVIM7m2AT6uaqwBeDctPtptPWPyvsPo5X0_QgQASDh2uMFYJ0BoAHqj4-GA8gBCakCxIxBTPsRhD6oAwHIA8sEqgT5AU_Q2iHdPPa4PKltH3Ud7k0t0FlqwFRjgg03QxcO1FccX94SjArnGps5w-87A8i5il0rmWXHYRcWOqVnQXs1sfaXzR2DwGuo5twD8SSuAnbafT24hHhDxjzH2R9RyyoMVFNP5wt7ezv8Lq18Ayn-zz3WefXLAdD6Y3FCJDrZQciWel18k5egnTkNW3LMtpsJzgiju1H5FnlHD3gkHl3x6IO_yfGzdmUvH_3H86MiijfK7YsNI4gHAOiaaVBQyypgsbqreeQovKi0WiS5azByZbx2hwT1u_HE4kQLw0HguhzT7ZYFf1TNl161W56fJyUQeSofYNSt-kWmOsAE44v8wP0DoAYugAepp4yjAagHjs4bqAeT2BuoB-6WsQKoB_6esQKoB6SjsQKoB9XJG6gHpr4bqAfz0RuoB5bYG6gHqpuxAqgH35-xAtgHANIIBwiAYRABGB-xCXPK57-tiWjagAoBmAsByAsBgAwBuAwBuBOIJ9gTDYgUAdAVAfgWAYAXAQ&ae=1&num=1&cid=CAASJeRo02vTqF9LgNFyxSPFdWReZVC_rdUCD88BoP4yoWENeONm0kE&sig=AOD64_0s6SSqx_Pvtue4vVcNvMAJZL35sg&client=ca-pub-9051032955849697&nb=8&adurl=https://cloud.tencent.com/act/new%3FfromSource%3Dgwzcw.6321087.6321087.6321087%26utm_medium%3Dcpc%26utm_id%3Dgwzcw.6321087.6321087.6321087%26gclid%3DEAIaIQobChMI2JTU55LK9wIVTjOWCh36nApWEAEYASAAEgISk_D_BwE)

腾讯云

打开

[

](https://www.googleadservices.com/pagead/aclk?sa=L&ai=Cnpx3x7J0YpiVIM7m2AT6uaqwBeDctPtptPWPyvsPo5X0_QgQASDh2uMFYJ0BoAHqj4-GA8gBCakCxIxBTPsRhD6oAwHIA8sEqgT5AU_Q2iHdPPa4PKltH3Ud7k0t0FlqwFRjgg03QxcO1FccX94SjArnGps5w-87A8i5il0rmWXHYRcWOqVnQXs1sfaXzR2DwGuo5twD8SSuAnbafT24hHhDxjzH2R9RyyoMVFNP5wt7ezv8Lq18Ayn-zz3WefXLAdD6Y3FCJDrZQciWel18k5egnTkNW3LMtpsJzgiju1H5FnlHD3gkHl3x6IO_yfGzdmUvH_3H86MiijfK7YsNI4gHAOiaaVBQyypgsbqreeQovKi0WiS5azByZbx2hwT1u_HE4kQLw0HguhzT7ZYFf1TNl161W56fJyUQeSofYNSt-kWmOsAE44v8wP0DoAYugAepp4yjAagHjs4bqAeT2BuoB-6WsQKoB_6esQKoB6SjsQKoB9XJG6gHpr4bqAfz0RuoB5bYG6gHqpuxAqgH35-xAtgHANIIBwiAYRABGB-xCXPK57-tiWjagAoBmAsByAsBgAwBuAwBuBOIJ9gTDYgUAdAVAfgWAYAXAQ&ae=1&num=1&cid=CAASJeRo02vTqF9LgNFyxSPFdWReZVC_rdUCD88BoP4yoWENeONm0kE&sig=AOD64_0s6SSqx_Pvtue4vVcNvMAJZL35sg&client=ca-pub-9051032955849697&nb=8&adurl=https://cloud.tencent.com/act/new%3FfromSource%3Dgwzcw.6321087.6321087.6321087%26utm_medium%3Dcpc%26utm_id%3Dgwzcw.6321087.6321087.6321087%26gclid%3DEAIaIQobChMI2JTU55LK9wIVTjOWCh36nApWEAEYASAAEgISk_D_BwE)

bat实现往hosts文件追加内容的更多相关文章

  1. nodejs文件追加内容

    const fs = require("fs"); // fs.appendFile 追加文件内容 // 1, 参数1:表示要向那个文件追加内容,只一个文件的路径 // 2, 参数 ...

  2. Java读取文件方法和给文件追加内容

    本文转载自:http://www.cnblogs.com/lovebread/archive/2009/11/23/1609122.html 1.按字节读取文件内容2.按字符读取文件内容3.按行读取文 ...

  3. 3 —— node —— 文件追加内容

    思想 : 先读取 , 再追加 const fs = require('fs') fs.readFile("./hello.txt","utf-8",(err,d ...

  4. Python之excel文件追加内容

    首先要安装三个模块:xlrd,xlwt,xlutils 命令:pip install xlrd xlwt xlutils 示例代码: #!/usr/bin/env python # -*- codin ...

  5. java文件相关(文件追加内容、文件内容清空、文件内容读取)

    https://blog.csdn.net/xnz0616/article/details/39137177 1.文件内容追加 // 在已有的文件后面追加信息 public static void a ...

  6. java:I/O 往原文件追加内容

    原来txt内容: "我要添加内容" import java.io.*; class Test { public static void main(String[] args) { ...

  7. hosts文件的内容

    C:\Windows\System32\drivers\etc\hosts 1 # Copyright (c) 1993-2009 Microsoft Corp. 2 # 3 # This is a ...

  8. 向HDFS中指定的文件追加内容,由用户指定内容追加到原有文件的开头或结尾。

    1 import java.io.FileInputStream; 2 import java.io.IOException; 3 import java.text.SimpleDateFormat; ...

  9. 修改window本地hosts文件,修改域名指向

    Hosts是一个没有扩展名的系统文件,可以用记事本等工具打开,其作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库”,当用户在浏览器中输入一个需要登录的网址时,系统会首先自动从Host ...

随机推荐

  1. sys.argv

    import sys i=0 print len(sys.argv) while i < len(sys.argv): print 'sys.argv[%d]:%s' %(i,sys.argv[ ...

  2. 关于tomcat8在windows2008下高并发下问题的解决方案

    因为客户服务器特殊的环境问题,只能使用windows2008r2服务器,然而配置过后,网站的高访问量很快就出现了各种问题,以下是解决的问题汇总. 服务器环境:windows2008R2+jdk8.0+ ...

  3. JSON.parse 函数应用 (复制备忘)

    JSON.parse 函数 JSON.parse 函数 (JavaScript) 将 JavaScript 对象表示法 (JSON) 字符串转换为对象. 语法 JSON.parse(text [, r ...

  4. WPF DataGrid 之数据绑定--实例2

    1.前台Grid定义 <!--数据绑定--> <DataGrid Grid.Row="1" Name="gridOne" Margin=&qu ...

  5. JavaSript模块化 && AMD CMD 详解.....

    模块化是指在解决某一个复杂问题或者一系列的杂糅问题时,依照一种分类的思维把问题进行系统性的分解以之处理.模块化是一种处理复杂系统分解为代码结构更合理,可维护性更高的可管理的模块的方式.可以想象一个巨大 ...

  6. HFS - 简单的将个人电脑变服务器!

    网络硬盘   HTTP File Server(HFS)是我目前所知道的最简便的P2P文件分享方式,只一个大小为559KB的单文件绿色软件(hfs.exe)就可以在瞬间不经过任何系统设置将一台普通的联 ...

  7. Kompose: Docker-compose 到 Kubernetes 的迁移工具

    Docker 让每个人都能够从 Docker Registry 启动一个打包好的 Docker 应用.Docker-Compose在Docker基础上解决了多容器应用之间的依赖启动问题. Docker ...

  8. Java部署项目命令学习小结

    前言: 暂无 零:java -h 和很多linux命令一样,我们第一步先通过“java -h”命令查看java命令的使用语法,其输出如下 [root@wxapp203 basesoft]# java ...

  9. css at @ 规则

    css相信我们都不陌生,但是我们真的对它非常了解吗? css主要分为两种规则组成: 一种被称为 at-rule,也就是 at 规则 另一种是 qualified rule,也就是普通规则 今天让我们来 ...

  10. Fedora 安装与常用命令

    fedora下载地址: https://getfedora.org/ 原来装的26,现在装27 用的是server版网络安装500多M 现在都是U盘安装了,fedora的写优盘说明 https://f ...


原网址: 访问
创建于: 2022-05-06 13:32:36
目录: default
标签: 无

请先后发表评论
  • 最新评论
  • 总共0条评论