How can i run program under cursor as admin?
Moderators: Hacker, petermad, Stefan2, white
How can i run program under cursor as admin?
I know about the method from the context menu. But I want to do it with a hotkey.
OS: Win10 | TC: latest x64
Re: How can i run program under cursor as admin?
Put this in your usercmd.ini file(located in the same place as your wincmd.ini):
If the file does not exist, just make it in a text editor.
Put for example this in the [Shortcuts] section of your wincmd.ini file:
If the section [Shortcuts] doesn't exist, just make it.
Then you can open files under the cursor by pressing Ctrl+Enter.
If you dont know where your wincmd.ini is located look in TC's menu at Help -> About Total Commander.
Code: Select all
[em_startelevated]
cmd=*%COMSPEC% /C
param=start "" %P%N
menu=Open file under cursor as Admin
iconic=1
Put for example this in the [Shortcuts] section of your wincmd.ini file:
Code: Select all
C+ENTER=em_startelevated
Then you can open files under the cursor by pressing Ctrl+Enter.
If you dont know where your wincmd.ini is located look in TC's menu at Help -> About Total Commander.
Last edited by petermad on 2022-08-23, 07:54 UTC, edited 1 time in total.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: How can i run program under cursor as admin?
nice!
this also work with .bat file?
without flashing cmd-window can be done?
this also work with .bat file?
without flashing cmd-window can be done?
OS: Win10 | TC: latest x64
Re: How can i run program under cursor as admin?
Then use this:this also work with .bat file?
without flashing cmd-window can be done?
Code: Select all
[em_startelevated]
cmd=*%COMSPEC% /C
param=if %E==bat (%P%N) else if %E==cmd (%P%N) else start "" %P%N
menu=Open file under cursor as Admin
iconic=1
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: How can i run program under cursor as admin?
when i run .bat (for example only with pause command) cmd-window starts minimized
10.51 rc2 x64
and i use hotkey CAS+ENTER=em_startelevated
10.51 rc2 x64
and i use hotkey CAS+ENTER=em_startelevated
OS: Win10 | TC: latest x64
Re: How can i run program under cursor as admin?
Then use:when i run .bat (for example only with pause command) cmd-window starts minimized
Code: Select all
iconic=0
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: How can i run program under cursor as admin?
is there a way to add nircmd?petermad wrote: 2022-08-23, 10:44 UTC but then you will se a short flash of a DOS console when you use the shortcut for other file types.
something like:
Code: Select all
cmd=*nircmd64.exe
param=exec hide cmd if %E==bat (%P%N) else if %E==cmd (%P%N) else if %E==ps1 (start powershell -ExecutionPolicy Bypass -NoExit -File %P%N) else start "" %P%N
OS: Win10 | TC: latest x64
Re: How can i run program under cursor as admin?
2KozakMak
It 's easier this way:
Command: *%WinDir%\System32\rundll32.exe url.dll,OpenURL
Parameters: %P%N
Personally, I also use an environment variable instead of this line, which sets it in autorun.cfg if the Windows version is higher than XP.
It 's easier this way:
But if not everything needs to be run with elevating (which is doubtful), then the solution is:Fla$her wrote: 2023-01-05, 08:23 UTCSet AlwaysAsAdmin=1 for the [Configuration] section and run TC with elevated rights from URL shortcut.
Command: *%WinDir%\System32\rundll32.exe url.dll,OpenURL
Parameters: %P%N
Personally, I also use an environment variable instead of this line, which sets it in autorun.cfg if the Windows version is higher than XP.
Overquoting is evil! 👎
Re: How can i run program under cursor as admin?
and what about .ps1?
example?Fla$her wrote: 2023-02-20, 09:55 UTC use an environment variable instead of this line, which sets it in autorun.cfg if the Windows version is higher than XP.
OS: Win10 | TC: latest x64
Re: How can i run program under cursor as admin?
For .ps1 I use the internal associations settings:
Type name: *.ps1
Open: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -nol -noni -nop -ex Bypass -f "%1"
Then, in the button or user command, we substitute %ADM% in front:
%ADM%"%COMMANDER_PATH%\Programs\Program.exe"
%ADM%"%COMMANDER_PATH%\Files\File.ext"
But in any case, the first option with ini is better, since it takes into account internal associations.
Type name: *.ps1
Open: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -nol -noni -nop -ex Bypass -f "%1"
Code: Select all
LoadLibrary Plugins\Autorun_Sysinfo.dll
StrMid OSVer %SYSINFO_OSVERSION% 5
If OSVer = 2000 Or OSVer = 'XP' Or OSVer = 2003 Or OSVer = '2003R2' Then
SetEnv ADM
Else
SetEnv /EV- ADM '*%WinDir%\System32\rundll32.exe url.dll,OpenURL '
EndIf
%ADM%"%COMMANDER_PATH%\Programs\Program.exe"
%ADM%"%COMMANDER_PATH%\Files\File.ext"
But in any case, the first option with ini is better, since it takes into account internal associations.
Overquoting is evil! 👎
Re: How can i run program under cursor as admin?
I need it all to be in one command, so I asked about nir
OS: Win10 | TC: latest x64
Re: How can i run program under cursor as admin?
2KozakMak
With .ps1 these tricks don't work (it's necessary to change the settings in the registry). And why open files with a hotkey at all, if there is Enter?
With .ps1 these tricks don't work (it's necessary to change the settings in the registry). And why open files with a hotkey at all, if there is Enter?
Overquoting is evil! 👎
Re: How can i run program under cursor as admin?
Ctrl+Alt+Shift+Enter
Code: Select all
[em_startelevated]
cmd=*%COMSPEC% /C
param=if %E==bat (%P%N) else if %E==cmd (%P%N) else if %E==ps1 (start powershell -ExecutionPolicy Bypass -NoExit -File %P%N) else start "" %P%N
OS: Win10 | TC: latest x64
Re: How can i run program under cursor as admin?
Ah, I didn't pay attention to ps1 check.
Command: *%COMMANDER_PATH%\Utils\NirCmd\nircmd.exe execmd
Parameters: "(if /i "%E"=="bat" (%V) else if /i "%E"=="cmd" (%V) else if /i "%E"=="ps1" (powershell.exe -nol -noni -nop -ex Bypass -f %V) else start "" %V)&"~$nir.exefile$" win postmsg foreground 1075 540"
However, this does not cancel my question about Enter.
Command: *%COMMANDER_PATH%\Utils\NirCmd\nircmd.exe execmd
Parameters: "(if /i "%E"=="bat" (%V) else if /i "%E"=="cmd" (%V) else if /i "%E"=="ps1" (powershell.exe -nol -noni -nop -ex Bypass -f %V) else start "" %V)&"~$nir.exefile$" win postmsg foreground 1075 540"
However, this does not cancel my question about Enter.
Last edited by Fla$her on 2023-02-20, 15:34 UTC, edited 1 time in total.
Overquoting is evil! 👎
Re: How can i run program under cursor as admin?
exe - ok
bat - do nothing
ps1 - open in notepad
¯\_(ツ)_/¯
bat - do nothing
ps1 - open in notepad
¯\_(ツ)_/¯
OS: Win10 | TC: latest x64