• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 586
  • Last Modified:

Startup shortcut

I need to add a link to my program in the StartUp folder for the current user.  I want to have this shortcut use a command line parameter of "/m".  I aslo want to delete this shortcut whenever I need to.  I want to do this only in my program and not in the setup program.  This also needs to work for Windows 95, 98, and NT 4.0 so I need to check for secruity permissions if it is NT.  I'll appreciate any help.  Thanks.
1 Solution
check out the VB fCreateShellLink() function.... that'll do what you want...

RaAuthor Commented:
and where do I find this function to check it out???  It is definitly not in help.  I type it in and the VB compiler says sub or function not defined.  I need more info.
Declare Function OSfCreateShellLink Lib "vb6stkit.dll" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String, ByVal fPrivate As Long, ByVal sParent As String) As Long

Check the setup1 program that comes with VB
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.

Ra, sorry,, i lost track of this question :)) Now as this guy added a comment I received e=mail... okay,..

Here is an example how to do it...

      Add a Command button (Command1) to Form1.

      .Add the following code to the General Declarations section of Form1:

                Option Explicit

                'NOTE: In Visual Basic 5.0, change Stkit432.dll in the following
                'statement to Vb5stkit.dll.

                Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal _
                 lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal _
                 lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long

                Sub Command1_Click()

                  Dim lReturn As Long

                  'Add to Desktop
                  lReturn = fCreateShellLink("..\..\Desktop", _
                  "Shortcut to Calculator", "c:\Winnt\system32\calc.exe", "")

                  'Add to Program Menu Group
                  lReturn = fCreateShellLink("", "Shortcut to Calculator", _
                  "c:\Winnt\system32\calc.exe", "")

                  'Add to Startup Group

                  'Note that on Windows NT, the shortcut will not actually appear
                  'in the Startup group until your next reboot.
                  lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", _
                  "c:\Winnt\system32\calc.exe", "")

                End Sub

      Press the F5 key to run the project, and then click the Command button.

      NOTE: If you are running Windows NT, the above example works correctly. If
      you are running Windows 95 or Windows 98, change the Calc.exe path to the


      This creates a shortcut to the Calc.exe file on the user's desktop, a program
      group, and a reference to it in the Startup items.

in any languaje?
Please grade!
RaAuthor Commented:
Thanks viktornet, it works great.  I already found out how to find if it already exist and to delete it if necessary.

Sorry it took so long for me to respond, I've been very busy with projects at work.

Thanks a bunch.
RaAuthor Commented:
Oh, one more thing.  I assume I can add something to the lpstrLinkArguments to make it start up minimized.  What do I need to do that?

Thanks again.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now