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

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Guillaume
Junior Member
Junior Member
Posts: 90
Joined: 2003-04-08, 16:51 UTC

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

Post 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?).
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post 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).
User avatar
Guillaume
Junior Member
Junior Member
Posts: 90
Joined: 2003-04-08, 16:51 UTC

Post 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.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post 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.
User avatar
Guillaume
Junior Member
Junior Member
Posts: 90
Joined: 2003-04-08, 16:51 UTC

Post by *Guillaume »

By pressing Enter on a .cmd or .bat file??
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Yes, BAT files too. But it is really bad to override Enter because entering/leaving folders doesn't work anymore.
User avatar
Guillaume
Junior Member
Junior Member
Posts: 90
Joined: 2003-04-08, 16:51 UTC

Post 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.
Post Reply