Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I retrieve into a variable the target of a shortcut?

5 views
Skip to first unread message

Timo Salmi

unread,
Sep 11, 2009, 6:55:13 AM9/11/09
to
DRAFT:

http://www.netikka.net/tsneti/info/tscmd177.htm

All the best, Timo

--
Prof. Timo Salmi mailto:t...@uwasa.fi ftp & http://garbo.uwasa.fi/
Hpage: http://www.uwasa.fi/laskentatoimi/english/personnel/salmitimo/
Department of Accounting and Finance, University of Vaasa, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm

Auric__

unread,
Sep 11, 2009, 10:56:44 AM9/11/09
to
On Fri, 11 Sep 2009 10:55:13 GMT, Timo Salmi wrote:

> DRAFT:
>
> http://www.netikka.net/tsneti/info/tscmd177.htm
>
> All the best, Timo

I would change the name to "How can I retrieve the target of a shortcut into
a variable?"

--
It looks like the Christmas Spirit threw up in our apartment.

ten.n...@virgin.net

unread,
Sep 11, 2009, 3:41:44 PM9/11/09
to
On Fri, 11 Sep 2009 13:55:13 +0300, Timo Salmi wrote:

> DRAFT:
>
> http://www.netikka.net/tsneti/info/tscmd177.htm
>
> All the best, Timo

Here's what I usually use:
::----- START -----
@ECHO OFF&SETLOCAL ENABLEEXTENSIONS
IF EXIST "%~1" (IF /I %~x1 NEQ .LNK GOTO :EOF
CALL :_) ELSE (GOTO :EOF)
FOR /F "DELIMS=" %%# IN ('CSCRIPT //NOLOGO "%%TEMP%%\_$.VBS" "%~1"') DO
ECHO %%#
DEL %TEMP%\_$.VBS&PING -n 3 127.0.0.1>NUL&GOTO :EOF
:_
>"%TEMP%\_$.vbs" ECHO WScript.Echo WScript.CreateObject^
("WScript.Shell").CreateShortcut(WScript.Arguments(0)).TargetPath
::------ END ------
The main difference from your example being that I check whether the input
file parameter (%1) is actually a shortcut before processing it.

Timo Salmi

unread,
Sep 11, 2009, 3:46:08 PM9/11/09
to
Auric__ <not.m...@email.address> wrote:
> On Fri, 11 Sep 2009 10:55:13 GMT, Timo Salmi wrote:
>> http://www.netikka.net/tsneti/info/tscmd177.htm

> I would change the name to "How can I retrieve the target of a shortcut into
> a variable?"

Done. Thanks.

Timo Salmi

unread,
Sep 11, 2009, 3:48:17 PM9/11/09
to
ten.n...@virgin.net wrote:
> On Fri, 11 Sep 2009 13:55:13 +0300, Timo Salmi wrote:
>> DRAFT:
>> http://www.netikka.net/tsneti/info/tscmd177.htm

> Here's what I usually use:
> ::----- START -----
:


> IF EXIST "%~1" (IF /I %~x1 NEQ .LNK GOTO :EOF
> CALL :_) ELSE (GOTO :EOF)

:


> The main difference from your example being that I check whether the input
> file parameter (%1) is actually a shortcut before processing it.

Good point!

0 new messages