Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Running a shortcut from within Foxpro
Message
 
À
23/04/2003 13:47:57
Len Wooden
Statistical Resources, Inc
Baton Rouge, Louisiane, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00780657
Message ID:
00780727
Vues:
8
>>The WSH Shell object does have problems running some lnk files. You'll get an "Access Denied" error with the more complex (3 Kb) short cut links. Another way to identify them is to check the shortcut tab of the properties dialog. The target area is shown as read-only. There's no problem with the standard lnk file and the run method.
>>
>>If you're not getting the message above, but rather one that says that the file can't be located, then it's probably being caused by a long file name, not enclosed in quotes.
>>
>>One alternative workaround would be to use the WSH to get an object reference to the shortcut, and then pass the TargetPath member to the Run method. To do this you'd use the WSH's Shell object's CreateShortcut method passing the lnk file name.
>
>Let's see if I have this correct George, I'm not getting an Access Denied msg, and the Target is not read-only.. so it rules that out.. I AM getting file can't be located and I am passing the long file name enclosed in quotes.. so in theory that shouldnt be it either.. but I will test on a short file name. As to the alternative method.. are you suggesting that using CreateShortcut will allow me to read the Target of an existing ShortCut??? -- if so.. that's the ticket!
>
Len,

First, since you seem to have some familarity with the WSH, you might use the Scripting.FileSystemObject's GetFile() method to get a reference to the link file, then use the ShortPath property as a parameter for the Run method of the Shell.

Second, the CreateShort method will return an object reference to an existing shortcut. The following displays the the target on the VFP main screen.
oShell = CREATEOBJECT('WScript.Shell')
lcpath = ADDBS(oShell.SpecialFolders('Desktop'))
lcfile = lcpath + "Microsoft Visual FoxPro 8.0.lnk"
oLNK = oShell.CreateShortcut(lcfile)
? oLNK.TargetPath
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform