@echo off
mode con cols=75 lines=25
title xxx平台外网访问
setlocal EnableDelayedExpansion&color 70 & cd /d "%~dp0"
rem %1 %2
rem ver|find "5.">nul&&goto :start
rem mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :start","","runas",1)(window.close)&goto :eof
rem %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
:start
@echo 本脚本使用方法是:放在nginx根目录,执行使用。
@echo 请注意你的杀毒软件提示,一定要允许
set host_path=C:\Windows\System32\drivers\etc\hosts
set domain=xx.xx.com
set domain2=127.0.0.1 xx.xxx.com xx.xxx.com xx.xxx.com
rem @echo "%domain%"
for /F %%j in ( 'type %host_path% ^| findstr %domain%' ) do ( set host_domain=%%j )
rem @type C:\Windows\System32\drivers\etc\hosts|findstr ***.***.cn > 1.txt
if "%host_domain%" == "" (
rem @echo bucunzai .....
rem echo %domain2% >> %host_path% rem 直接插入不换行
rem @echo %domain2% >> %host_path% rem 换行后插入
@echo %domain2% >> %host_path%
) else (
rem @echo run nginx
rem call :runPathAllExe %host_path%
rem @echo %nginx_path%
)
@call :runNginx
@echo 您现在已经可以访问了,按任意键关闭此窗口。 && pause>nul
@exit
:runNginx
set nginx_path=%~dp0nginx.exe
taskkill /f /t /IM nginx.exe > nul
rem echo %nginx_path%
start %nginx_path%
rem :runPathAllExe
rem rem @echo %~dp1data\nginx.exe
rem for /f "delims=" %%i in ('dir /a-d /s /b "%~dp1\*.exe"') do (start "" "%%i")
rem
rem
rem :print
rem rem 本脚本文件全路径 %~s0==%0
rem set file_all_path=%~s0
rem echo %file_all_path%
rem rem 获取到文件所在路径
rem rem %~dp0:本脚本文件所在路径 %~dp1:call调用时传入的参数(文件全路径)的文件所在路径
rem set file_path=%~dp1
rem echo %file_path%
rem rem 获取到文件名称
rem set file_name=%~n1
rem echo %file_name%
rem rem 获取到文件后缀
rem set suffix=%~x1
rem echo %suffix%
rem rem 截取倒数第四个开始 截取四个长度
rem set specStr=%file_name:~-4,4%
rem echo %specStr%
rem pause
上一篇
MySQL优化
2021-01-25
下一篇
Windows 常用命令
2020-10-27