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

How to get target path from Windows Installer Shortcuts with VBSCRIPT

251 views
Skip to first unread message

Mark Melanson

unread,
Mar 23, 2004, 3:15:54 PM3/23/04
to
Is there anyway to do it? I have had no luck finding anything specific to VBSCRIPT.

Phil Wilson

unread,
Mar 23, 2004, 4:19:43 PM3/23/04
to
Do you mean a WSH VBScript or a custom action VBScript?
--
Phil Wilson [MVP Windows Installer]
----
"Mark Melanson" <Junk...@NoSpam.mailshell.com> wrote in message
news:9c0f9649.04032...@posting.google.com...

Phil Wilson

unread,
Mar 23, 2004, 7:38:05 PM3/23/04
to
I've been trying Installer.GetShortcutTarget - that would be part of a VBScript
solution - but can't get it to work If you already know the productcode and the
component GUID for the shortcut (which you'd get from GetShortcutTarget), you
could use Installer.ComponentPath to return the path to it.

--
Phil Wilson [MVP Windows Installer]
----
"Mark Melanson" <Junk...@NoSpam.mailshell.com> wrote in message
news:9c0f9649.04032...@posting.google.com...

Rich [Microsoft Windows Installer MVP]

unread,
Mar 26, 2004, 5:10:01 PM3/26/04
to
[Please do not mail me a copy of your followup]

=?Utf-8?B?QnJldHQgQXJtaXN0ZWFk?= <anon...@discussions.microsoft.com> spake the secret code
<E8C79F34-893D-4458...@microsoft.com> thusly:

>I could get GetShortcutTarget to work in VB but not VBS.

The typelib and the documentation are incorrect about the name of the
method. Its really ShortcutTarget. Using that knowledge I can get it
to call the method, but I can't get the contents of the binary
descriptor from vbscript, so the method still fails:

option explicit
dim wi : set wi = CreateObject("WindowsInstaller.Installer")
dim fso : set fso = CreateObject("Scripting.FileSystemObject")
dim lnk : lnk = "C:\Documents and Settings\All Users\Start " &_
"Menu\Programs\Microsoft DirectX 9.0 SDK Update (Summer 2003)\DirectX " &_
"Sample Browser.lnk"
dim rec : set rec = wi.ShortcutTarget(lnk)
wscript.echo rec.stringdata(1)
wscript.echo rec.stringdata(2)
wscript.echo rec.stringdata(3)

If you look at MsiGetShortcutTarget, which is wrapped by the
automation interface, it takes a string that contains the "descriptor"
for the shortcut, not the path to a shortcut file. I don't know how
you could get the shortcut descriptor in vbscript without writing your
own helper COM object, sine the scripting interface only gives you a
method of reading a text file's contents, not the contents of a binary
file.
--
"The Direct3D Graphics Pipeline"-- code samples, sample chapter, FAQ:
<http://www.xmission.com/~legalize/book/>
Pilgrimage: Utah's annual demoparty
<http://pilgrimage.scene.org>

Phil Wilson

unread,
Mar 26, 2004, 7:15:06 PM3/26/04
to
With Rich's hint I could get it working. This is an example:

option explicit
dim inst, apath, arecord, prod, comp, target
set inst = createobject("WindowsInstaller.Installer")
apath ="C:\Documents and Settings\All Users\Start
Menu\Programs\Phil\Notepad\Shortcut to NOTEPAD.EXE.lnk"
set arecord = inst.ShortcutTarget (apath)
prod = arecord.StringData(1)
comp = arecord.StringData(3)
target = inst.ComponentPath (prod, comp)
msgbox target

which is this in C++

WCHAR pc [50] = {0};
WCHAR feat [100] = {0};
WCHAR comp [50] = {0};
UINT i = MsiGetShortcutTargetW(L"C:\\Documents and Settings\\All Users\\Start
Menu\\Programs\\Phil\\Notepad\\Shortcut to NOTEPAD.EXE.lnk",
pc, feat, comp);
WCHAR pth [500] = {0};
DWORD chs = 500;
i = MsiGetComponentPath (pc, comp, pth, &chs);

--
Phil Wilson [MVP Windows Installer]
----

"Rich [Microsoft Windows Installer MVP]" <legaliz...@mail.xmission.com>
wrote in message news:%23jomW83...@TK2MSFTNGP11.phx.gbl...

Rich [Microsoft Windows Installer MVP]

unread,
Mar 26, 2004, 9:57:59 PM3/26/04
to
[Please do not mail me a copy of your followup]

"Phil Wilson" <phil....@unisys.spamcom> spake the secret code
<OSIJQC5E...@TK2MSFTNGP12.phx.gbl> thusly:

>With Rich's hint I could get it working. [...]

Ah, I see what I did wrong. The shortcut I tested was installed by an
MSI, but it wasn't an *advertised* shortcut, so the function failed.
It worked when I tried it on the shortcut installed by Orca.

0 new messages