Solved

desktop shortcut

Posted on 2000-03-17
11
787 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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 27

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 27

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

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