Created
September 27, 2015 18:24
-
-
Save ty0x2333/30f2abf3bfbfd297ce29 to your computer and use it in GitHub Desktop.
Chrome外部应用协议安装和卸载脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>Launch Custom URL </title> | |
<script type="text/javascript"> | |
function LaunchURLScript(){ | |
var url = "TyStart:"; | |
window.open(url); | |
self.focus(); | |
} | |
</script> | |
</head> | |
<body style="background-color:#D7D7D7"> | |
<input type="submit" name="Launch" id="Launch" value="Launch Custom URL" onclick="LaunchURLScript()"> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo ===================================================== | |
echo TyStart - 外部启动协议安装/卸载 | |
echo By luckytianyiyan@gmail.com | |
echo ===================================================== | |
echo 1. 正在检查权限... | |
Rem 创建文件路径 | |
set TempFile_Name=%SystemRoot%\System32\BatTestUACin_SysRt%Random%.batemp | |
Rem 写入文件 | |
( echo "BAT Test UAC in Temp" >%TempFile_Name% ) 1>nul 2>nul | |
Rem 判断写入是否成功 | |
if not exist %TempFile_Name% ( | |
echo 需要管理员身份运行 | |
echo 请右键"以管理员身份运行"重新运行该.bat文件 | |
Rem 删除临时文件 | |
del %TempFile_Name% 1>nul 2>nul | |
goto End | |
) | |
Rem 删除临时文件 | |
del %TempFile_Name% 1>nul 2>nul | |
echo 权限通过... | |
echo 2. 检查是否已安装... | |
echo 若提示 "系统找不到指定的注册表项或值" 请忽略 | |
:: REG QUERY "HKEY_CLASSES_ROOT" /s|find "TyStart" | |
REG QUERY "HKEY_CLASSES_ROOT\TyStart\shell\open" /s|find "command" | |
IF ERRORLEVEL 1 goto Install | |
set /p order=请输入重装[re/r]或者卸载[un/u](默认重装): | |
if "%order%"=="un" goto Uninstall | |
if "%order%"=="u" goto Uninstall | |
:Install | |
echo 3. 正在安装... | |
set /p dirName=请输入安装目录(默认C:\TyyTools\TyStart): | |
if "%dirName%"=="" set dirName=C:\TyyTools\TyStart | |
if not exist %dirName% md %dirName% | |
set fName=%dirName%\TyStart.bat | |
echo 3.1 创建脚本%fName% | |
echo @echo off >%fName% | |
echo echo =====================================================>>%fName% | |
echo echo TyStart - 外部启动协议>>%fName% | |
echo echo By luckytianyiyan@gmail.com>>%fName% | |
echo echo =====================================================>>%fName% | |
echo set param=%%1>>%fName% | |
echo set "fileName=%%param:tystart://=%%">>%fName% | |
echo if "%%param%%"=="%%fileName%%" goto End>>%fName% | |
echo start "" %%fileName%%>>%fName% | |
echo :End | |
echo 脚本创建成功 | |
echo 3.2 协议写入注册表 | |
reg add "HKEY_CLASSES_ROOT\TyStart" /ve /t REG_SZ /d "URL:TyStart Protocol" | |
reg add "HKEY_CLASSES_ROOT\TyStart" /v "URL Protocol" /t REG_SZ | |
reg add "HKEY_CLASSES_ROOT\TyStart\shell\open\command" /ve /t REG_SZ /d "%fName% %%1" | |
echo 安装成功! | |
echo 最后一步!运行 "Launch Custom URL.html" 点击按钮, 在弹窗中勾选不在询问并点击加载 | |
echo 完成 | |
echo 可以在浏览器中使用形如 "tystart://J:\" 来启动 exploerer 打开"J:\"文件夹 | |
echo 亦或是形如 "tystart://J:\HelloWord.exe" 来启动 "J:\HelloWord.exe"应用 | |
goto End | |
:Uninstall | |
echo 4. 正在卸载... | |
Setlocal enabledelayedexpansion | |
for /f "skip=2 delims=: tokens=1,*" %%i in ('Reg Query "HKEY_CLASSES_ROOT\TyStart\shell\open\command" /ve') do ( | |
set str=%%i | |
set var=%%j | |
set "var=!var:"=!" | |
if not "!var:~-1!"=="=" set value="!str:~-1!:!var!" | |
) | |
for /f "delims=" %%a in ('"echo %value%"') do (set lj=%%~dpa) | |
rd /s /q %lj% | |
reg delete "HKEY_CLASSES_ROOT\TyStart" /f | |
echo 卸载成功! | |
:End | |
pause | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment