I have a case where in I have an installed package and need to read the arguments for an advertised shortcut installed by it. This is to be done via a custom action in a new package. Currently, I am using the Win32_ShortcutAction class and a corresponding WMI query to read the arguments. The problem is that the script takes alot of time to get the arguments. Is there a more efficient way to do this.
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Reading Arguments for Advt Shortcuts
Started by
KapilMarwah
, Feb 04 2005 15:35
2 replies to this topic
Posted 05 February 2005 - 12:28
The closest I can come up with is the following script, and it doesn't work on all shortcuts. I'm not sure why, but the "ShortcutTarget" property of the "Installer" object doesn't always return the component guid - the SDK confirms this, but doesn't explain why!
But, I'm thinking that you might actually know the component GUID of the shortcut you're trying to examine? If you do, then you don't need the information in the third field of the record object - so it should always work.
Const iOPENDBRO = 0
Set oInst = CreateObject("WindowsInstaller.Installer")
oRS = oInst.CreateRecord(3)
Set oRS = oInst.ShortcutTarget("D:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Office\Microsoft Office Tools\Microsoft Office Application Recovery.lnk")
sProdCode = oRS.Stringdata(1)
sCompGuid = oRS.Stringdata(3)
sDBPath = oInst.ProductInfo(sProdCode, "LocalPackage")
Set oDB = oInst.OpenDataBase(sDBPath, iOPENDBRO)
sQuery = "SELECT `Component` FROM `Component` WHERE `ComponentId` = '" & sCompGuid & "'"
Set oView = oDB.OpenView(sQuery)
oView.Execute
Set oRecord = oView.Fetch
sCompName = oRecord.StringData(1)
sQuery = "SELECT `Arguments` FROM `Shortcut` WHERE `Component_` = '" & sCompName & "'"
Set oView = oDB.OpenView(sQuery)
oView.Execute
Set oRecord = oView.Fetch
Msgbox oRecord.StringData(1)
But, I'm thinking that you might actually know the component GUID of the shortcut you're trying to examine? If you do, then you don't need the information in the third field of the record object - so it should always work.
Const iOPENDBRO = 0
Set oInst = CreateObject("WindowsInstaller.Installer")
oRS = oInst.CreateRecord(3)
Set oRS = oInst.ShortcutTarget("D:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Office\Microsoft Office Tools\Microsoft Office Application Recovery.lnk")
sProdCode = oRS.Stringdata(1)
sCompGuid = oRS.Stringdata(3)
sDBPath = oInst.ProductInfo(sProdCode, "LocalPackage")
Set oDB = oInst.OpenDataBase(sDBPath, iOPENDBRO)
sQuery = "SELECT `Component` FROM `Component` WHERE `ComponentId` = '" & sCompGuid & "'"
Set oView = oDB.OpenView(sQuery)
oView.Execute
Set oRecord = oView.Fetch
sCompName = oRecord.StringData(1)
sQuery = "SELECT `Arguments` FROM `Shortcut` WHERE `Component_` = '" & sCompName & "'"
Set oView = oDB.OpenView(sQuery)
oView.Execute
Set oRecord = oView.Fetch
Msgbox oRecord.StringData(1)
Posted 07 February 2005 - 08:38
Thanks Mandy.....I also thought of this but it won't work for my case.... The Arguments I need to read are substituted Public Properties. If i use the ShortcutTarget and then read the subsequent shortcut table..i would get the unresolved property.. ehich is not useful.....so i need something which could read the Args from the installed shortcut.....
something like Win32_ShortcutAction class.......
Kapil
something like Win32_ShortcutAction class.......
Kapil