Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to automatically create program shortcut after the s
Message
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00177116
Message ID:
00190858
Views:
27
>>>>>As we know, the setup wizard can create distribution disk images. I use the images to setup my application but cannot create a shortcut on the desktop or in the start menu automatically at the end. I guess the "Post-installation executing program" during the setup wizard must be the answer, but how to make it.
>>>>
>>>>You'll need to access the IShellLink API to create the shortcuts; George Tasker has created a wrapper .DLL that makes the IShellLink API accessible from within VFP; it can be downloaded from the files section here on UT. If you have the Windows Scripting Host installed on the target system, the Wscript.Shell OLE Automation object has a set of methods that make the IShellLink API available through the Automation object; it can create shortcuts not only for a local resource, but also for URLs (links to the InterNet).
>>>
>>>Thanks Ed. I got the wrapper .DLL, but still can't make it out. Can you show me how to code it, practically.
>>
>>As mentioned, I don't use George's wrapper, since I prefer to use the Wscript.Shell automation object, but you might ask George, since he's around here, too. I'd recommend posting the code you've tried to use, and tell him what it is or is not doing.
>>
>>A simple example of how the Wscript.Shell object works would be:
>>
>>oWSH = CREATEOBJ('Wscript.Shell')
>>oShortcut = oWSH.CreateShortcut("C:\WINDOWS\Desktop\My Shortcut.lnk")
>>oShortcut.TargetPath = "C:\MyDir\MyApp.EXE OneCmdLineParm AnotherParm"
>>oShortcut.WorkingDirectory = "\\SomeServer\MyAppShare\SomeDirectory"
>>oShortcut.Save
>>
>>George's .DLL has similar functionality; I'm sure if you read his docs you can figure it out.
>
>What is "Windows Scripting Host"? How to install it? Your solution is simple, I like it. Where do you put those codes?

The Windows Scripting Host is a scripting facility first integrate into Win98; it can be added to almost any Win32 system (it's a component of the WinNT Option Pack, and there is a freely redistributable self-extracting .EXE, WSH.EXE, available from Microsoft. It's an optional component that's added to systems automatically when you install something like IIS4 or PWS also) It provides a script execution facility with a number of built-in automation objects, as well as the ability to execute scripts written using VBScript or JScript. The three main automation objects in WSH, Wscript.Shell, Wscript.Network and Scripting.FileSystemObject, are available to VFP once WSH is installed on the system, and they provide access to a large number of APIs that are otherwise difficult to use without wrapper .DLLs or third-party add-ons.

That's actual VFP code BTW (if you had the directories and files named in the example, at least); if the WSH is installed, you can use code similar to that within your VFP programs to create a shortcut. For example, you might create a post-setup executable for your installation that would create a shortcut on the Windows desktop rather than in the start menu. You can also read and modify an existing shortcut this way.

I learned about WSH initially while developing ASP scripts for IIS; the MSDN documents the automation objects pretty thoroughly, and the best way to learn how the stuff works is to play with it. If you have access to the MSDN, look at the FileSystemObject, WshNetWork and WshShell topics for a starting point in the documentation. I'd consider MSDN to be a must-have resource, whether you're using APIs, automation, or just developing software that might go beyond the general realm of VFP-centric programming.

There are a number of other good places to go to find out more about WSH; Windows NT Systems (a magazine that I read; subscription information is available at http://www.ntsystems.com) just started what I think will be a good series on WSH in their Inside the Box column; there are also a number of web sites devoted to scripting issues such as http://cwashington.netreach.net/site/scripts, which focuses on scripting issues in general. John Petersen also wrote an article on using WSH in VFP which covers WSH from a VFP perspective; you can get back issues from http://www.pinpub.com/foxtalk, and can download individual articles from their web site for $5/each, including source code for the subscriber downloads.

Good luck

Ed
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform