Page 1 of 1

Ctrl+Shift+Enter on batch to elevate & keep window opene

Posted: 2017-11-20, 22:47 UTC
by Guillaume
I've been looking for a way to quickly open a .cmd / .bat file as Administrator and keep the window opened.

Shift+Enter already runs the batch file and keeps the window opened. Perhaps Ctrl+Shift+Enter could be used to open elevated and keep command prompt opened?

If there's any alternative, I'd love to hear so. Actually, after reading this, I thought there would be a way to set Run&Keep window as default (with Enter), OR at least always let TC show the internal associations popup on Enter. However, it seems that with current versions (9.10-9.12RC4) .bat/.cmd Enter can not be overwritten (anymore?).

Posted: 2017-11-21, 06:58 UTC
by MVV
You can assign any command to Ctrl+Shift+Enter, but it will be the only command for all file types. If you want to start elevated batch and keep window opened, you can use e.g. following command:

Code: Select all

Command: %ComSpec%
Parameters: /k "cd /d "%P" & call "%P%N""
Just go to Options/Misc, select Ctrl+Shift+Enter shortcut and define such a command in usercmd.ini category (which is intended for user-defined commands).

Posted: 2017-11-21, 12:01 UTC
by Guillaume
MVV wrote:You can assign any command to Ctrl+Shift+Enter, but it will be the only command for all file types. If you want to start elevated batch and keep window opened, you can use e.g. following command:

Code: Select all

Command: %ComSpec%
Parameters: /k "cd /d "%P" & call "%P%N""
Just go to Options/Misc, select Ctrl+Shift+Enter shortcut and define such a command in usercmd.ini category (which is intended for user-defined commands).
You forgot the asterisk * before %comspec%, but yeah, that'll work for this. Thanks!

I was distracted by trying to overwrite Enter via internal associations. Still don't get why that shouldn't work.

Posted: 2017-11-21, 14:11 UTC
by MVV
Yes, you're right, I've missed the asterisk.

Code: Select all

Command: *%ComSpec% 
Parameters: /k "cd /d "%P" & call "%P%N""
Strange, I've just tried to associate cm_Config with ENTER key, and it works: I press Enter on a file and get configuration dialog.

Posted: 2017-11-21, 15:50 UTC
by Guillaume
By pressing Enter on a .cmd or .bat file??

Posted: 2017-11-21, 17:57 UTC
by MVV
Yes, BAT files too. But it is really bad to override Enter because entering/leaving folders doesn't work anymore.

Posted: 2017-11-21, 18:25 UTC
by Guillaume
Oooh you meant it like that. No, I wanted to overwrite it for .cmd & .bat only via internal associations. That doesn't work, sadly.