@echo off&pushd %~dp0
taskkill /f /im chro* >nul 2>nul
taskkill /f /im goo* >nul 2>nul
ping -n 2 127.0.0.1 >nul
rem 安装前移除垃圾文件夹
rd /s /q "%~dp0User Data\Default\GPUCache" >nul
rd /s /q "%~dp0User Data\Default\JumpListIcons" >nul
rd /s /q "%~dp0User Data\Default\JumpListIconsOld" >nul
rd /s /q "%~dp0User Data\ShaderCache" >nul
rd /s /q "%~dp0User Data\PnaclTranslationCache" >nul
rem 为垃圾文件夹建立链接，让垃圾文件夹统一指向临时文件夹
mklink /d "%~dp0User Data\Default\GPUCache" %temp% >nul
mklink /d "%~dp0User Data\Default\JumpListIcons" %temp% >nul
mklink /d "%~dp0User Data\Default\JumpListIconsOld" %temp% >nul
mklink /d "%~dp0User Data\ShaderCache" %temp% >nul
mklink /d "%~dp0User Data\PnaclTranslationCache" %temp% >nul

rem 允许任意网站Flash总是运行
reg add "HKLM\SOFTWARE\Policies\Google\Chrome" /f /v "AllowOutdatedPlugins" /t REG_DWORD /d 1
reg add "HKLM\SOFTWARE\Policies\Google\Chrome" /f /v "RunAllFlashInAllowMode" /t REG_DWORD /d 1
reg add "HKLM\SOFTWARE\Policies\Google\Chrome" /f /v "DefaultPluginsSetting" /t REG_DWORD /d 1
reg add "HKLM\SOFTWARE\Policies\Google\Chrome\PluginsAllowedForUrls" /f /v "1" /t REG_SZ /d "https://*"
reg add "HKLM\SOFTWARE\Policies\Google\Chrome\PluginsAllowedForUrls" /f /v "2" /t REG_SZ /d "http://*"

rem 建立快捷方式
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\谷歌浏览器.lnk""):b.TargetPath=""%~dp0Chrome.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\卸载.lnk""):b.TargetPath=""%~dp0卸载.bat"":b.WorkingDirectory=""%~dp0"":b.Save:close")
rem 通过注册表查询获取到桌面的路径
for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop"') do (
rem 获取到桌面的路径存储到迭代变量，并传给变量desk
set desk=%%j
)
rem 将快捷方式同步到开始菜单
md "C:\ProgramData\Microsoft\Windows\Start Menu\Google Chrome" >NUL 2>NUL
copy /y "%desk%\谷歌浏览器.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Google Chrome\谷歌浏览器.lnk"
move /y "%desk%\卸载.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Google Chrome\卸载.lnk"
start Chrome.exe 