+[8.5b2] Param %S and Run As Admin Conflict

Bug reports will be moved here when the described bug has been fixed

Moderators: Hacker, petermad, Stefan2, white

SWZ
Junior Member
Junior Member
Posts: 10
Joined: 2013-07-07, 00:37 UTC

+[8.5b2] Param %S and Run As Admin Conflict

Post by *SWZ »

If I specify %S in the parameter of a button in the button bar, 'Run As Admin' is ignored. The simplest example may be:

Code: Select all

cmd=*%ComSpec%
param=/k echo %P%S
The same with %R, too. If use %N instead, it works as expected.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, parameters using list files are not compatible with "as administrator". Why? TC has to wait for the called program to terminate (to delete the temporary list file), which isn't possible if the program runs in a different user account.
Author of Total Commander
https://www.ghisler.com
SWZ
Junior Member
Junior Member
Posts: 10
Joined: 2013-07-07, 00:37 UTC

Post by *SWZ »

It's %S, not %L. Am I missing something here?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Ah, sorry, I didn't look close enough. %S doesn't work because I have to use CreateProcess instead of ShellExecute, because CreateProcess supports a much longer command line. However, CreateProcess doesn't support elevation. I could use ShellExecute for shorter command lines and CreateProcess for longer, but then you would get the problem suddenly when selecting more than a certain number of files. :(
Author of Total Commander
https://www.ghisler.com
SWZ
Junior Member
Junior Member
Posts: 10
Joined: 2013-07-07, 00:37 UTC

Post by *SWZ »

I was never concerned about the commandline length limit, so I guess 2048 is enough with me. But not so sure about other users as it's indeed far too shorter than 32767. Since I may workaround the problem by passing the command to powershell I suppose better leave the current behaviour as it is to avoid confusion.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

If you always need to run button as admin, you can use my Sudo tool, it works even with %L. It uses ShellExecuteEx function and passes command line as is w/o truncation.
It is quite easy in use: just insert full path to Sudo.exe before your program path in Command: field.
SWZ
Junior Member
Junior Member
Posts: 10
Joined: 2013-07-07, 00:37 UTC

Post by *SWZ »

MVV wrote:If you always need to run button as admin, you can use my Sudo tool, it works even with %L.
I was aware of it but I didn't use it as there's only x86 version and I'm on x64 and concerned about the path redirections, 'System32/SysWOW64' and 'Sysnative/System32'. Anyway, powershell is handy too for this job as far as the commandline doesn't need quotes.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Maybe I should show an error when %S is used and the command line becomes too long for ShellExecute...
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Sounds good!
SWZ
Junior Member
Junior Member
Posts: 10
Joined: 2013-07-07, 00:37 UTC

Post by *SWZ »

I like that too!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

For now, I have just enabled it without a warning, because there seem to be several length limits - for example, cmd.exe seems to have a limit of 2047 characters, while ShellExecute has one of 8191 (on Windows 7).
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I think help note would be enough.
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

Sorry, my question is not directly related to the subject of this topic.

Hello MVV. Does sudo.exe return the error code of the executed application? I did not find information file in the zip. Are you planning to prepare/share 64 bit version of it?

Best wishes
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Please try updated Sudo.
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

MVV, 1 hour 52 minutes :shock:

You are very fast! It should be higher than $50000 :wink:

Thanks

EDIT > They worked well. Sudo64.exe can run both 32 bit and 64 bit applications, excellent... Thanks again
Post Reply