?
Solved

VB6 Shortcut to .exe put on desktop of Windows 7 and Vista machines

Posted on 2010-03-22
6
Medium Priority
?
526 Views
Last Modified: 2012-05-09
Please help me put a shortcut to the following file on the desktop of a Windows 7 and Vista machine:

c:\Program Files\Rorschach Scoring Trainer\Scoring Trainer.exe

Thanks!
0
Comment
Question by:toddlengnick
  • 3
  • 2
6 Comments
 

Author Comment

by:toddlengnick
ID: 28308977
for clarity's sake: I need to know how to program this to happen in VB6...
0
 
LVL 23

Expert Comment

by:debuggerau
ID: 28309333
I used to use the Visual Basic 6.0 Package and Deployment Wizard to define all the files to distribute.
I then use the target directory of %USERPROFILE%\desktop to save the icon too..
0
 
LVL 9

Expert Comment

by:Karen
ID: 28313425
oh dear...it's me again :)

Replace with your own values in the following, and choose from either "this user" or "all users"...

Public Sub CreateShortcut()
Dim WSHShell         As Object
Dim ShellLink        As Object
Dim UserDesktopPath  As String
Dim EXEPath          As String
Dim ShortcutTitle    As String

    Set WSHShell = CreateObject("WScript.Shell")
    ' To create a shortcut for the current user ONLY:
    UserDesktopPath = WSHShell.SpecialFolders("Desktop")
    ' To create a shortcut for ALL USERS:
    UserDesktopPath = WSHShell.SpecialFolders("AllUsersDesktop")
    EXEPath = "C:\PathToYourFile\YourFileName.exe"
    ShortcutTitle = "TEST"
   
    Set ShellLink = WSHShell.CreateShortcut(UserDesktopPath & "\" & ShortcutTitle & ".lnk")
    ShellLink.TargetPath = EXEPath
    ShellLink.IconLocation = EXEPath
    ShellLink.WorkingDirectory = EXEPath
    ShellLink.Save
   
    Set ShellLink = Nothing
    Set WSHShell = Nothing
End Sub
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:toddlengnick
ID: 29388609
Snowberry,


This works great in XP... will this also work with Windows 7 and Vista?

Thank you!
0
 
LVL 9

Accepted Solution

by:
Karen earned 2000 total points
ID: 29875840
Hi toddlengnick,

It works for me under Vista... unfortunately I don't have access to a Windows 7 machine so I cannot test it myself, but I cannot see why it wouldn't work on it too.

Also I can see that I have put something wrong... you should probably change

  ShellLink.WorkingDirectory = EXEPath

to

  ShellLink.WorkingDirectory = UserDesktopPath
0
 

Author Closing Comment

by:toddlengnick
ID: 32050435
Got it - this works great - thank you for all your help!
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
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 Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
Suggested Courses

601 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