Solved

desktop shortcut

Posted on 2000-03-17
11
790 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
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

790 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