We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
首先创建fetch_github_hosts.bat文件并写入以下内容
@echo off powershell -Command "& { $remote='https://raw.hellogithub.com/hosts'; $hostsPath='%SystemRoot%\System32\drivers\etc\hosts'; $reader=[System.IO.StreamReader]::new($hostsPath, $true); $hostsContent=$reader.ReadToEnd(); $encoding=$reader.CurrentEncoding; $reader.Close(); $newContent=$encoding.GetString((Invoke-WebRequest -Uri $remote -UseBasicParsing).Content).TrimEnd(); $pattern='(?s)# GitHub520 Host Start.*?# Github520 Host End'; $newHostsContent=$hostsContent -replace $pattern, ''; if (-not $newHostsContent.EndsWith([Environment]::NewLine)) { $newHostsContent+=[Environment]::NewLine; } [System.IO.File]::WriteAllText($hostsPath, $newHostsContent + $newContent, $encoding); }" echo GitHub hosts updated successfully!
然后使用使用管理员身份运行以下cmd命令添加到task schtasks,会在每天05:00运行fetch_github_hosts.bat文件,记得把path\to\fetch_github_hosts.bat修改为你的文件所在路径
schtasks /create /tn FetchGithubHosts /tr "path\to\fetch_github_hosts.bat" /sc DAILY /st 05:00 /ru SYSTEM /rp "" /rl HIGHEST /f
然后如果要手动运行,使用管理员身份运行以下cmd命令
schtasks /run /tn FetchGithubHosts
如果要删除task schtasks,使用管理员身份运行以下cmd命令
schtasks /delete /tn FetchGithubHosts /f
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
No branches or pull requests
首先创建fetch_github_hosts.bat文件并写入以下内容
然后使用使用管理员身份运行以下cmd命令添加到task schtasks,会在每天05:00运行fetch_github_hosts.bat文件,记得把path\to\fetch_github_hosts.bat修改为你的文件所在路径
然后如果要手动运行,使用管理员身份运行以下cmd命令
schtasks /run /tn FetchGithubHosts
如果要删除task schtasks,使用管理员身份运行以下cmd命令
schtasks /delete /tn FetchGithubHosts /f
The text was updated successfully, but these errors were encountered: