?
Solved

desktop shortcut

Posted on 2000-03-17
11
Medium Priority
?
804 Views
Last Modified: 2010-05-02
How do I create a new shortcut on the Win 95 Desktop from within my VB5  created application ? I need to add a user name as a command-line parameter after the first usage of my application.
0
Comment
Question by:dierdan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +4
11 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2630786
0
 
LVL 4

Expert Comment

by:jkunal
ID: 2630794
Ruchi Do you work for Yahoo?.......
You got a really fast search......


;->
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2630812
Jkunal..Nope, I don't work for Yahoo ;-)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:jkunal
ID: 2630820
That was just a comment for you search speed........

;->
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2630980
jkunal... always keep vbnet handy - the code library answers a heck of a lot of the questions posted here <smile>
0
 
LVL 14

Accepted Solution

by:
mcrider earned 2000 total points
ID: 2631142
Add the following to a MODULE:

    Declare Function OSfCreateShellLink Lib "VB5STKIT.DLL" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String) As Long
   


Then you can do this:

        Dim ShortcutName As String
        Dim OrigPath As String
       
        ShortcutName = "Shortcut To WordTime"
        OrigPath = "D:\Utilities\wordtime.com"
       
        OSfCreateShellLink "..\..\Desktop", _
            ShortcutName, OrigPath, Chr$(0)




Cheers!®©
0
 
LVL 1

Expert Comment

by:Maquiavelo
ID: 2631533
 There's another sample at:

www.thescarms.com
0
 
LVL 28

Expert Comment

by:Ark
ID: 2632351
Hi
The easiest way is to use Windows Scripting Host. Take a look at http://support.microsoft.com/support/kb/articles/Q244/6/77.ASP. Sample 2 show, how to add command line parameter. Cheers
0
 
LVL 28

Expert Comment

by:Ark
ID: 2632395
Hi
Here is code you want:
'Make reference (VB Menu -> Project -> Reference) to Windows Scripting Host

Private Sub Command1_Click()
   Dim wshShell As New IWshShell_Class
   Dim wshNetwork As New IWshNetwork_Class
   Dim oMyShortCut As IWshShortcut_Class
   Dim sDeskTop As String, sUserName As String
   sDeskTop = wshShell.SpecialFolders.Item("Desktop")
' Set your shortcut name
   Set oMyShortCut = wshShell.CreateShortcut(sDeskTop + "\MyTest.lnk")
'Set window style
   oMyShortCut.WindowStyle = 7 ' &&Minimized 0=Maximized  4=Normal
'Set icon for your shortcut
   oMyShortCut.IconLocation = "d:\vb50\graphics\icons\computer\msgbox01.ico"
'Set target app
   oMyShortCut.TargetPath = "c:\Windows\calc.exe"
'Get user name
   sUserName = wshNetwork.UserName
'Set arguments for shortcut
   oMyShortCut.Arguments = sUserName
'Set working directory
   oMyShortCut.WorkingDirectory = "c:\windows"
'Save shortcut
   oMyShortCut.Save
End Sub
Cheers
0
 

Author Comment

by:dierdan
ID: 2632663
I was overwelmed by good answers and references. I choose this one because I cohld easily try it ( and it did excactly what I wanted) and it is the most elegant.Thanks to you all and special thanks to mcrider.
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2633372
Thanks for the points! Glad I could help!


Cheers!®©
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question