Is it possible to get Total Commander's variables like %P, %N, etc. without surrounding quotes for space containing path

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Akon
Junior Member
Junior Member
Posts: 10
Joined: 2018-09-24, 15:30 UTC

Is it possible to get Total Commander's variables like %P, %N, etc. without surrounding quotes for space containing path

Post by *Akon »

Consider following - creating Total Commander's user command like this:

Code: Select all

Command: %comspec%
Parameters: ? /c runas /user:<USERNAME> "notepad %N"
As "runas"'s documenation says, paths with spaces must look like this (notice escaped qoutes there - \"):

Code: Select all

> runas /user:<USERNAME> "notepad \"my file.txt\""
However, with %N = "my file.txt" the command appears as follow:

Code: Select all

> runas /user:<USERNAME> "notepad "my file.txt""
That breaks "runas"'s expecting syntax.

One possible solution is getting %N without surrounding quotes. Is it possible somehow?

In particular, are there any alternative ways exist to execute "runas" command with specified arbitrary user like above?

P.S. I know that asterisk '*' in front of the command name forces to start a command with admin rights. Two asterisks '**' - to start as a different user seems not working for me (in TotalCommander 8.51a).
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Is it possible to get Total Commander's variables like %P, %N, etc. without surrounding quotes for space containing

Post by *MVV »

Unfortunately there are some Windows tools that expect command line with quotes in a single argument instead of just taking the rest of command line.

You can try %P%O.%E - this will produce combined full path to a file w/o any quotes.
Akon
Junior Member
Junior Member
Posts: 10
Joined: 2018-09-24, 15:30 UTC

Re: Is it possible to get Total Commander's variables like %P, %N, etc. without surrounding quotes for space containing

Post by *Akon »

Indeed, %P%O.%E looks suitable.

I had experimented with these macros not enough. Thank you!
Post Reply