How to run command from command line as admin?

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
KozakMak
Senior Member
Senior Member
Posts: 370
Joined: 2021-05-24, 12:39 UTC
Location: UA

How to run command from command line as admin?

Post by *KozakMak »

Maybe there is some kind of hotkey for this?

PS. I know about * in buttons, i need from command line directly.
OS: Win10 | TC: latest x64
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6498
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: How to run command from command line as admin?

Post by *Horst.Epp »

Select "As Administrator" from the right click of your normal Cmd button.
There is no hotkey or anything else for this.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
KozakMak
Senior Member
Senior Member
Posts: 370
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: How to run command from command line as admin?

Post by *KozakMak »

Ctrl+Shift+Enter (as in Win+R) would be nice.

Move the topic then to "TC suggestions".
OS: Win10 | TC: latest x64
JOUBE
Power Member
Power Member
Posts: 1477
Joined: 2004-07-08, 08:58 UTC

Re: How to run command from command line as admin?

Post by *JOUBE »

KozakMak wrote: 2024-02-05, 17:15 UTC I know about * in buttons, i need from command line directly.
Support++.

I also want to have that * in the command line.

Thanks for making this suggestion.

I try to use it - really - every day... for example "*cmd" and it doesn't work...

It is simple and fast and perfectly to use, faster than every hotkey.

Hopefully simple to implement and perfect for adding it in Tc11.03rc05

Joube

Please Moderators: Move this threat to forum "suggestions". Thanks
NotNull
Senior Member
Senior Member
Posts: 269
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: How to run command from command line as admin?

Post by *NotNull »

Workaround ...

I wrote SUDO.cmd that can help here. Using it daily without issues, but there might be some edge cases that I haven't run into (yet).
Start SUDO without parameters ans it will launch an elevated CDM prompt.
Start it with SUDO <your command> [options for your command], like sudo regedit -m and it will run that command elevated.
Put sudo.cmd somewhere where TC can find it.





SUDO.cmd

Code: Select all

@echo off

:: Create dummy script
	set RANDOM=>"%temp%\%~n0.ELEVATE"

:: File association: Run .ELEVATE always elevated
	reg add HKCU\Software\Classes\.elevate /ve /D MaartenElevate /F >nul
	reg add HKCU\Software\Classes\MaartenElevate\Shell\runas\command /ve /D "cmd.exe /c pushd \"%%w\" & start \"%~n0\" %%*" /F >nul

:: Execute dummy .ELEVATE script
	"%temp%\%~n0.ELEVATE" %*

:: Clean up
rem	reg delete HKCU\Software\Classes\.elevate /F >nul
rem	reg delete HKCU\Software\Classes\MaartenElevate /F >nul
rem	del /Q "%temp%\%~n0.ELEVATE"

JOUBE
Power Member
Power Member
Posts: 1477
Joined: 2004-07-08, 08:58 UTC

Re: How to run command from command line as admin?

Post by *JOUBE »

NotNull wrote: 2024-02-05, 19:17 UTC Workaround ...

sudo.cmd
Ok, nice.

I use "elevate" elevate - Command-Line UAC Elevation Utility for things like this. *)

...but would prefere the TCs * at the Tc command line

Joube

*) and IsAdmin for already Admin checks and so on...
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: How to run command from command line as admin?

Post by *white »

Moderator message from: white » 2024-02-06, 00:19 UTC

Moved to Suggestions forum.
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to run command from command line as admin?

Post by *petermad »

Support++ for * also working in the command line
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
NotNull
Senior Member
Senior Member
Posts: 269
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: How to run command from command line as admin?

Post by *NotNull »

JOUBE wrote: 2024-02-05, 20:42 UTC and IsAdmin for already Admin checks
Completely off-topic:

AdminCheck.cmd

Code: Select all

@whoami /groups | findstr /i "S-1-16-16384 S-1-16-12288" >nul && echo YES || echo NO

But as said: workaround. Would be a good thing if this suggestion got implemented.
JOUBE
Power Member
Power Member
Posts: 1477
Joined: 2004-07-08, 08:58 UTC

Re: How to run command from command line as admin?

Post by *JOUBE »

NotNull wrote: 2024-02-07, 20:57 UTC Would be a good thing if this suggestion got implemented.
Yes, also for everyone who is familiar with the command line and usually uses the command line. This is quicker, easier and more convenient than selecting a menu or a button or special hotkeys and so on.

Your suggestion++.

Joube
Post Reply