Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RunAsTI] Please add "Open command prompt here as TI" #9

Open
ggbbrr opened this issue Oct 7, 2023 · 2 comments
Open

[RunAsTI] Please add "Open command prompt here as TI" #9

ggbbrr opened this issue Oct 7, 2023 · 2 comments

Comments

@ggbbrr
Copy link

ggbbrr commented Oct 7, 2023

Similar to the more common "open command prompt here" or "open command prompt here as admin".

(for directories & directory background)

Thanks.

@AveYo
Copy link
Owner

AveYo commented Oct 12, 2023

It's doable but then how many different prompts will you end up with?
It's trivial to start cmd in powershell as TI

@ggbbrr
Copy link
Author

ggbbrr commented Oct 14, 2023

Here's how I currently do it with NSudo. And I find it very useful to just right click a folder and choose this option :

`@ECHO off
SETLOCAL EnableDelayedExpansion
CD /d "%~dp0"

NET SESSION >NUL 2>&1
IF NOT %ERRORLEVEL% == 0 (
ECHO Please run this batch file as ADMIN. Aborting
PAUSE
EXIT
)

SET "_file_name=NSudoLC.exe"

)
SET "_file_path=%~dp0%_file_name%"
SET "_menu_text=Open command prompt here as TI (NSudo)"
SET "_keycommand=Command"
SET "_keyicon=Icon"
SET "_regkey1=HKCU\Software\Classes\Drive\shell%_menu_text%"
SET "_regkey2=%_regkey1%%_keycommand%"
SET "_regkey3=HKCU\Software\Classes\Directory\shell%_menu_text%"
SET "_regkey4=%_regkey3%%_keycommand%"
SET "_regkey5=HKCU\Software\Classes\Directory\Background\shell%_menu_text%"
SET "_regkey6=%_regkey5%%_keycommand%"

IF NOT EXIST "%_file_path%" (
ECHO error : Cannot find "%_file_name%" in current directory. Exiting.
PAUSE
EXIT
)

REG.EXE QUERY "%_regkey1%" /ve >NUL 2>NUL
IF ERRORLEVEL 1 (
CHOICE /c ix /n /m "Type i to install '%_menu_text%'. Or type x to exit:"
IF errorlevel 2 EXIT

REG.EXE add "%_regkey2%" /v "" /t REG_SZ /d "\"%~dp0%_file_name%\" -U:T cmd.exe /s /k pushd \"%%V\"" /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : creating reg key "%_regkey2%". & PAUSE

REG.EXE add "%_regkey1%" /v "%_keyicon%" 		/t REG_SZ /d "\"%~dp0%_file_name%\",0"  /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : creating reg key "%_regkey1%". & PAUSE

REG.EXE add "%_regkey4%" /v "" /t REG_SZ /d "\"%~dp0%_file_name%\" -U:T cmd.exe /s /k pushd \"%%V\"" /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : creating reg key "%_regkey4%". & PAUSE

REG.EXE add "%_regkey3%" /v "%_keyicon%" 		/t REG_SZ /d "\"%~dp0%_file_name%\",0"  /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : creating reg key "%_regkey3%". & PAUSE

REG.EXE add "%_regkey6%" /v "" /t REG_SZ /d "\"%~dp0%_file_name%\" -U:T cmd.exe /s /k pushd \"%%V\"" /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : creating reg key "%_regkey6%". & PAUSE

REG.EXE add "%_regkey5%" /v "%_keyicon%" 		/t REG_SZ /d "\"%~dp0%_file_name%\",0"  /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : creating reg key "%_regkey5%". & PAUSE

) ELSE (
CHOICE /c ux /n /m "Type u to UNinstall '%_menu_text%'. Or type x to exit:"
IF errorlevel 2 EXIT

reg.exe delete "%_regkey1%" /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : deleting reg key "%_regkey1%". & PAUSE

reg.exe delete "%_regkey3%" /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : deleting reg key "%_regkey3%". & PAUSE

reg.exe delete "%_regkey5%" /f >NUL 2>NUL
if ERRORLEVEL 1 ECHO  ERROR : deleting reg key "%_regkey5%". & PAUSE

)

EXIT

`
If you think it's worth doing ...
Or even correcting the code above ... :-)

Thanks, anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants