Last active
June 5, 2025 09:43
-
-
Save 5j9/0bdeab3f0d1179b2a6ef46281b2434c8 to your computer and use it in GitHub Desktop.
telegram link default app handler installer/uninstaller .cmd
This file contains hidden or 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 | |
setlocal EnableDelayedExpansion | |
:: Check for admin privileges | |
net session >nul 2>&1 | |
if not %ERRORLEVEL%==0 ( | |
:: Request admin elevation | |
echo set UAC = CreateObject^("Shell.Application"^) > "%temp%\elevate.vbs" | |
echo UAC.ShellExecute "cmd.exe", "/k %~s0", "", "runas", 1 >> "%temp%\elevate.vbs" | |
cscript //nologo "%temp%\elevate.vbs" | |
del "%temp%\elevate.vbs" | |
exit /b | |
) | |
:: Prompt for Telegram.exe path | |
set /p telegramPath=Enter the full path to Telegram.exe (e.g., C:\Path\To\Telegram.exe): | |
set telegramPath=%telegramPath:"=% | |
:: Register tg:// protocol in HKEY_CLASSES_ROOT | |
reg add "HKEY_CLASSES_ROOT\tg" /ve /d "URL:Telegram Protocol" /f >nul | |
reg add "HKEY_CLASSES_ROOT\tg" /v "URL Protocol" /d "" /f >nul | |
reg add "HKEY_CLASSES_ROOT\tg\shell\open\command" /ve /d "\"%telegramPath%\" -- \"%%1\"" /f >nul | |
echo Done! Telegram is set to open tg:// links. | |
echo Test with a tg:// link (e.g., tg://resolve?domain=telegram) in your browser. | |
pause |
This file contains hidden or 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 | |
setlocal EnableDelayedExpansion | |
:: Check for admin privileges | |
net session >nul 2>&1 | |
if not %ERRORLEVEL%==0 ( | |
:: Request admin elevation | |
echo set UAC = CreateObject^("Shell.Application"^) > "%temp%\elevate.vbs" | |
echo UAC.ShellExecute "cmd.exe", "/k %~s0", "", "runas", 1 >> "%temp%\elevate.vbs" | |
cscript //nologo "%temp%\elevate.vbs" | |
del "%temp%\elevate.vbs" | |
exit /b | |
) | |
:: Remove tg:// protocol from registry | |
reg delete "HKEY_CLASSES_ROOT\tg" /f >nul | |
echo Done! The tg:// protocol has been removed from the registry. | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment