Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

desktop shortcut

Posted on 2000-03-17
11
Medium Priority
?
811 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
Industry Leaders: 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!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
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…
Suggested Courses

609 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