Run as... working folder problem

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
msh
Junior Member
Junior Member
Posts: 2
Joined: 2008-05-21, 13:32 UTC

Run as... working folder problem

Post by *msh »

Hello,
I need to use "Run as..." option from right click menu on specific programs. The program's start in folders (working folder) must be their current directories (otherwise they crash).
when I use "Run as..." option in TC (even for the current user), they crash.
To work around this problem, I create lnk files with pre defined start in directories and with these lnk files, "Run as..." worked.

Is there any other way to use "Run as..." without creating lnk files in TC for working directory definition problem?

Thank you in advance
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50475
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No, unfortunately there isn't - TC uses InvokeCommand to execute Start menu entries, it has no influence on the start path and other parameters.
Author of Total Commander
https://www.ghisler.com
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

You could use this in context menu as a workaround:

Code: Select all

REGEDIT4

[HKEY_CLASSES_ROOT\*\shell\RunAsAdmin]
@="&RunAsAdmin"

[HKEY_CLASSES_ROOT\*\shell\RunAsAdmin\command]
@="\"C:\\WINDOWS\\system32\\RunAs.exe\" /user:\"Administrator\" \"C:\\WINDOWS\\system32\\cmd.exe /c cd /d \"\"\"%1\\..\"\"\"&&start \"\"\"\"\"\" \"\"\"%1\"\"\"\""
(tested on XP SP2)
Admin user name and windows directory have to be adjusted to your case (system variables seem to be not working here).


Edit: Added start command for automated removal of temporary cmd window.
Last edited by StatusQuo on 2008-05-24, 15:08 UTC, edited 1 time in total.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hi, Status Quo.

How about adding the internal command of cmd.exe, start, in front of the final "%1", i.e. launching start "%1"?

With all the escaped double quotes I did not dare insert the "start" command into your registry source code. Will leave this to you. :wink:

Prefixing the "start" command should make the cmd.exe window close once the start command has been executed.

Regards,
Karl
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2karlchen
Prefixing the "start" command
Thanks, that's indeed the solution. I already tried that, but (again) forgot about start's "title" parameter, so it just opened another cmd window instead of the selected program.
(It has to be: start "" "%1".)

I now updated (and successfully tested) the code above.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hi, StatusQuo,

oh yes, I remember stumbling across this need to insert a(n empty) title into the start commandline.
This results in even a few more escaped double quotes in your registry source code.

I am starting to feel haunted by escaped double quotes. I am going to have an "escaped double quotes" nightmare tonight and wake up shouting out in panic, "You need to escape them!" But there will be no escape ... :wink:

Great workaround / solution for the reported issue by the way. :)

Karl
msh
Junior Member
Junior Member
Posts: 2
Joined: 2008-05-21, 13:32 UTC

Post by *msh »

Hi all,

Thank you very much for your kind concern and workarounds
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2msh
Thanks for reporting back, nice to hear that it seems to fit your needs, too.

2karlchen
Thanks, I hope you sleep better meanwhile. ;)
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
Post Reply