Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

The SHORTCUT command again,..

Apr
318
7
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:
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
 
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.
 
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.
 
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.
 
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?
 
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
 
... 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
 
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
 
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:
The error persists in a shell opened with
Code:
start /i /pgm "%_cmdspec" /i
which is about a clean as you can get.
 
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?
 
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: 237
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

Back
Top