当前位置 : 主页 > 网络编程 > JavaScript >

update-hosts.js

来源:互联网 收集:自由互联 发布时间:2021-06-28
update-hosts.js // 请用管理员权限运行var request = require('sync-request');var fs = require('fs');var url = 'https://coding.net/u/scaffrey/p/hosts/git/raw/master/hosts-files/hosts';var co = request('GET', url).getBody().toString();
update-hosts.js
// 请用管理员权限运行

var request = require('sync-request');
var fs = require('fs');

var url = 'https://coding.net/u/scaffrey/p/hosts/git/raw/master/hosts-files/hosts';

var co = request('GET', url).getBody().toString();
fs.renameSync(`C:/windows/system32/drivers/etc/hosts`, `C:/windows/system32/drivers/etc/hosts.bak`);
fs.writeFileSync(`C:/windows/system32/drivers/etc/hosts`, co);
console.log('done..');
网友评论