The SHORTCUT command again,..

Apr 13, 2010
314
7
61
The Hague
I posted about this before but it turns out my initial idea that quoting didn't work was wrong. You *can* have embedded double-quotes in the arguments to the SHORTCUT command. Forget escaping, just concatenate them. (Thanks, Vince.)

What you *cannot* have is %envar% expansion. The WINAPI allows them, PowerShell supports it, you can put them in manually, but TC doesn't allow them in the arguments to the SHORTCUT command.

I will post a change request in the appropriate forum.
 
Last edited:
May 20, 2008
11,520
102
Syracuse, NY, USA
Where do you want environment variable expansion. It seems OK here. But one thing you can't do is (for example)

Code:
v:\> shortcut %%systemroot%%\system32\net.exe ...

What winds up in the shortcut is

Code:
v:\%systemroot%\system32\net.exe
 
Apr 13, 2010
314
7
61
The Hague
I might want them in the hyperlink fields for program, arguments or working directory. They are very useful in situations where programs and data are not always in the same location on different machines, for different users or memory devices. The shortcuts remain the same under different circumstances. But you know that, so... what is it you're asking?

Your point in example is my point: it doesn't work, but it should. It is a limitation imposed by TC, not windows. This limitation serves no purpose that I am aware of.
 
May 20, 2008
11,520
102
Syracuse, NY, USA
Your point in example is my point: it doesn't work, but it should. It is a limitation imposed by TC, not windows.
Is that the only point? It has nothing to do with environment variables. Envvars work normally with the SHORTCUT command; %varname% is expanded immediately and %%varname%% puts %varname% into the shortcut's properties. The only problem I can find is TCC's prepending drive:\ to something that doesn't look like a fully-qualified name. As far as I can tell, that's the only place using %%envvar%% causes trouble.

The help says the target must be fully-qualified. I think TCC should leave that to the user and not try to be helpful.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,491
90
Albuquerque, NM
prospero.unm.edu
I just dug out the source for my MKSC command, and its default behavior is to canonicalize the target filename unless the first character is a percent sign and the second is a letter. I guess my assumption was that an environment variable would almost always come at the start of the target name.

I'm not sure now whether that was a clever assumption or a stupid one, but it is a very simple test. It would probably take Rex, oh, about 90 seconds to implement something similar in SHORTCUT.
 
Apr 13, 2010
314
7
61
The Hague
Thank you for your reply, Charles.

It does seem like a lot of hoopla about something not quite complicated.

I am a little worried though, that the discussion seems to zoom-in on the "command" argument to SHORTCUT. In my experience, it also doesn't allow %envar% in the "arguments" and "directory" ... parts. There are no helpful error messages however, so the user is left guessing what goes wrong where.

Envvars work normally with the SHORTCUT command; %varname% is expanded immediately and %%varname%% puts %varname% into the shortcut's properties.

... is what I'm looking for, but doesn't work at my side, using version 25.00.17 .

Can you confirm, please?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,491
90
Albuquerque, NM
prospero.unm.edu
Here, SHORTCUT tries to canonicalize the "command" and "directory" args, even if they contain a variable reference. The "args" arg, however, is left alone:

Code:
C:\>ver /r

TCC  25.00.20 x64   Windows 10 [Version 10.0.17763.737]
TCC Build 20   Windows 10 Build 17763
Registered to COE-DN00071735

C:\>shortcut c:\Windows\System32\notepad.exe %%args%% %%startdir%% "" C:\Users\cdye\desktop\Notepad.lnk 1

C:\>shortcut C:\Users\cdye\desktop\Notepad.lnk
Command=C:\Windows\System32\notepad.exe
Arguments=%args%
Directory=C:\%startdir%
Description=
Link=C:\Users\cdye\desktop\Notepad.lnk
Icon=
Offset=0
Mode=1
Hotkey=

C:\>

Link properties.png
 
May 20, 2008
11,520
102
Syracuse, NY, USA
... is what I'm looking for, but doesn't work at my side, using version 25.00.17 .

Can you confirm, please?
Code:
v:\> ver

TCC  25.00.20 x64   Windows 10 [Version 10.0.18362.356]

v:\> set stuff=junk

v:\> SHORTCUT x:\%stuff%\%%stuff%%\foo.exe "/k echo %stuff% %%stuff%%" v:\ Desc v:\test.lnk 1

1569595515317.png
 
May 20, 2008
11,520
102
Syracuse, NY, USA
Here's another. You see that it handles the environment variables correctly. As far as I can tell, the only thing that's undesirable is the prepending of a drive specification.

Code:
v:\> set stuff=junk

v:\> SHORTCUT %%stuff%%\%stuff%\foo.exe "/k echo %stuff% %%stuff%%" v:\ Desc v:\test.lnk 1

1569596072084.png
 
Apr 13, 2010
314
7
61
The Hague
Thanks, guys. This is helpful (in a way) in that the examples that work on your end fail at mine. Pffft. Thank goodness. Só glad it is not something obvious. :banghead: I just know this is gonna hurt!
 
Last edited:
Apr 13, 2010
314
7
61
The Hague
The error persists in a shell opened with
Code:
start /i /pgm "%_cmdspec" /i
which is about a clean as you can get.
 
May 20, 2008
11,520
102
Syracuse, NY, USA
The error persists in a shell opened with
Code:
start /i /pgm "%_cmdspec" /i
which is about a clean as you can get.
What is the error? Please tell us, show us ... what do you do? ... what do you expect/want to happen? ... what actually happens?
 
Apr 13, 2010
314
7
61
The Hague
Hi Vince, Charles. I appreciate your efforts.

What is the error? Please tell us, show us ... what do you do? ... what do you expect/want to happen? ... what actually happens?

I would say, nothing special...
 

Attachments

  • Knipsel.PNG
    Knipsel.PNG
    38.5 KB · Views: 103
May 20, 2008
11,520
102
Syracuse, NY, USA
To avoid the (bogus) error message, give the LNK file a path.
Code:
v:\> SHORTCUT %_winsysdir\notepad.exe %%args%% %%dir%% "" notepad.lnk 1
TCC: (Sys) The operation completed successfully.
 "C:\WINDOWS\system32\notepad.exe"

v:\> SHORTCUT %_winsysdir\notepad.exe %%args%% %%dir%% "" v:\notepad.lnk 1

v:\> shortcut notepad.lnk
Command=C:\Windows\System32\notepad.exe
Arguments=%args%
Directory=V:\%dir%
Description=
Link=notepad.lnk
Icon=
Offset=0
Mode=1
Hotkey=

There's another problem. At runtime, Explorer will not know what %args% and %dir% mean. So it's unclear where notepad will start, and you'll get

1569857028738.png
 
Similar threads
Thread starter Title Forum Replies Date
S SHORTCUT command question Support 1
S SHORTCUT command failure Support 1
S Desktop hotkey creation using SHORTCUT command Support 4
E Bug in shortcut command Support 2
vefatica Literal double quotes in SHORTCUT's "args" parameter? Support 6
C How to bypass UAC warning when shortcut in \Startup folder ? Support 9
D [cosmetic] Shortcut for v24 still has v23 in its comment Support 1
vefatica New Shortcut Key box Support 1
M TCC Taskbar Shortcut Breaks Support 1
C How to? SHORTCUT question..... Support 6
R Shortcut key assignments - default Support 0
vefatica Shortcut/start-up folder nonsense Support 20
samintz How to? Use tilde shortcut Support 3
vefatica Keeping taskbar-pinned shortcut? Support 6
G How to? Trying to create TCC shortcut that opens with blue background (on Windows 8.1 x64) Support 1
vefatica Update removes pinned shortcut? Support 17
noahcoad How to? Create shortcut with env var in path Support 4
vefatica Must update remove my taskbar-pinned shortcut? Support 20
vefatica Update removes taskbar-pinned shortcut Support 7
A Limitation regarding creation of shortcut keys for "copy" Support 0
nickles How to? Shortcut evaluation Support 5
vefatica SHORTCUT behavior (Win7) Support 3
C starting a shortcut from desktop Support 14
N Shortcut stops working after 4NT to TCC Upgrade Support 73
S Desktop Shortcut Hotkey question Support 1
D Always get shortcut in Start Menu folder Support 6
S OT: WinXP shortcut vs. junctions Support 2
M "Shortcut key" on Windows start menu shortcuts Support 5
Z CMDDebug - TCC unknown command Support 2
F Edit command Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 28.02.17 Support 0
old coot LEAVE appears to affect command-line arguments Support 11
J VDESKTOP command Support 3
old coot tee command cancels colors Support 33
Dmitry L. Kobyakov How to? How to remove the record of the old version of the Take Command? Support 9
D Can alias pass parameters to for command? Support 3
samintz How to? Search for %(command) in Help? Support 1
T VIEW only works from command line Support 14
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) [SOLVED] Support 1
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
vefatica `Back quotes` - command line vs. batch file Support 5
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
T How to? retain command history across reboot? Support 6

Similar threads