【批处理脚本】bat解决谷歌浏览器跨域问题

  1. 新建TXT文件,复制粘贴以下代码
@echo off
:Start
set index=""
for /f "delims=="  %%i in ('where chrome') do set index="%%i"
echo "%index%"
if %index%=="" (goto A) else (goto GOON)
:GOON
for /f "delims=\, tokens=1,*" %%a in (%index%) do (
	::echo %%a %%b
	set index= "%%b"
	if /i not %index% =="chrome.exe" ( 
		set str=%str%%%a%\
		goto GOON
	)

)
echo %str%
cd /d %str%

cls
echo 浏览器跨域打开成功!!!
call chrome.exe --disable-web-security --user-data-dir=C:\MyChromeUserFata
goto End

:A
cls
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
color 0a
echo 抱歉,找不到您谷歌的位置,请复制粘贴谷歌的位置;
echo 我们将会帮你把谷歌路径添加到系统变量里
echo eg:  "C:\Program Files\Google\Chrome\Application"
echo eg:"C:\Users\Wasabi\AppData\Local\Google\Chrome\Application"
set /p startip=请粘贴谷歌位置:
echo %PATH%
wmic ENVIRONMENT where "name='path' and username=''" set VariableValue="%path%;%startip%"
::setx /m PATH "%PATH%;%startip%"
set path=%path%;%startip%
goto Start


:End
  1. 修改文件后缀为 bat
  • 若出现乱码问题,文件需另存为 编码为"ANSI"模式
  1. 双击运行 bat 文件即可

你可能感兴趣的:(网络安全,文档解析,前端开发,服务器,linux,运维,网络安全)