Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a desktop shortcut. 1

Status
Not open for further replies.

ChrisN

Programmer
Jul 9, 2001
59
0
0
GB
When deploying an application (using P&DW) is it possible to create desktop shortcuts pointing to the executable and other distributed folders/files?

Hope someone can help me out.

Cheers,
Chris
 
Chrisn, I see you entered your request Nov. 2001. Did you get any answers? I have the same problem.
Easyreader@eircom.net
 
Here is the code that will place an item on the desktop

You will need to include the following reference into the project:

Windows Script Host Object Model

'-------

Sub fCreateShortcutOnDesktop()

Dim WSHShell As IWshRuntimeLibrary.IWshShell_Class
Dim WSHShortcut As IWshRuntimeLibrary.IWshShortcut_Class
Dim strFullFilePathName As String
Dim strDesktopPath As String
Dim strFileName As String
Dim strPath As String

' Create a Windows Shell Object
Set WSHShell = New IWshRuntimeLibrary.IWshShell_Class

' Set the file's name and path...

strPath = "C:\vb_projs\LineCount\"
strFileName = "LineCount" ' Note without .exe
strFullFilePathName = strPath + strFileName

' Read desktop path using WshSpecialFolders object
strDesktopPath = WSHShell.SpecialFolders.Item("Desktop")

' Create a shortcut object on the desktop
Set WSHShortcut = WSHShell.CreateShortcut(strDesktopPath & "\" & strFileName & ".lnk")

' Set shortcut object properties and save it
With WSHShortcut
.TargetPath = WSHShell.ExpandEnvironmentStrings(strFullFilePathName)
.WorkingDirectory = WSHShell.ExpandEnvironmentStrings(strPath)
.WindowStyle = 4
.Save
End With
fCreateShortcutOnDesktop = 1

Set WSHShell = Nothing

End Sub

'===============

I'll leave the error handling code up to you

To have this done by the PDW, place this subroutine in the Setup1 project of the PDW and call it at the right time.

See my posts in Thread222-246643 or search the Thread for suggestions on modifying the Setup1 project of the PDW or you can search the thread - there have been quite a few posts on the Desktop Shortcuts and PDW issues. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Great post Lightseeker. Works great. Just what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top