Solved

desktop shortcut

Posted on 2000-03-17
11
785 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now