=?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>
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...
"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.