Results 1 to 5 of 5

Thread: VB6 Create/Delete Shortcuts including Special Folders like Startup

  1. #1

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    VB6 Create/Delete Shortcuts including Special Folders like Startup

    I couldn't find any working code showing how to create and delete Startup menu shortcuts.
    I feel it's the best way to have your program start when Windows boots because it's easy for even a nubee user to get rid of it.

    This code requires VB6 and the vb6stkit.dll.
    I've tested it and it works on WinXP.

    You don't need the Windows Scripting Host or the System File Object.
    And it doesn't mess with the registry.

    Why add the dependencies or risk being flagged a Virus risk?

    The download contains the Shortcuts and Special Folders module and it has a form for testing some of the module procedures.

    The GetSpecialFolderPath function uses an Enum to make it easy to use.

    I believe this will work on Win98 and up.
    But I need some people to test it and let me know for sure.

    Thx and enjoy!
    ----------------------------------

    Just made fixes to the HasStartupShortcut function.
    Wrote it without testing it

    Posting version 1.01 now

    P.S.
    I forgot to mention that this module should be able to make shortcuts anywhere and has subs specifically for making them on the Desktop, in Programs Menu, and in Startup Menu.
    Attached Files Attached Files
    Last edited by longwolf; Oct 6th, 2008 at 09:39 PM. Reason: fixing the title

  2. #2

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: Create/Delete Shortcuts including Special Folders like Startup

    Fixed the path to modShortcutsAndSpecialFolders.bas
    Added a descriptive label to the form.
    Attached Files Attached Files

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VB6 Create/Delete Shortcuts including Special Folders like Startup

    here is another method using scripting, but will work fine in vb6 /vba
    vb Code:
    1. 'Create a WshShell Object
    2. Set wshshell = CreateObject("Wscript.Shell")
    3.  
    4. ' select shortcut name and folder
    5. Set oshelllink = wshshell.CreateShortcut(wshshell.specialfolders("allusersstartup") & "\aaa.lnk")
    6.  
    7. 'Set the Target Path for the shortcut
    8. oshelllink.TargetPath = "notepad.exe"
    9.  
    10. 'Set the additional parameters for the shortcut
    11. oshelllink.Arguments = "c:\windows\desktop\aaa.txt"
    12.  
    13. 'Save the shortcut
    14. oshelllink.Save
    15.  
    16. 'Clean up the WshShortcut Object
    17. Set oshelllink = Nothing
    18. Set wshshell = Nothing
    Last edited by westconn1; Oct 17th, 2008 at 06:18 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: VB6 Create/Delete Shortcuts including Special Folders like Startup

    Thx Westconn1,
    But part of the idea was to avoid using the Windows Scripting Host and the System File Object.

    But if you like it, go for it

    I think the way I designed the GetSpecialFolderPath function (I know, very long name) is still very helpful.

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VB6 Create/Delete Shortcuts including Special Folders like Startup

    i seldom use FSO unless for vb script, but some scripting and WMI makes a lot of tasks much simpler
    as i said, this is just an alternative

    as you say with getspecialfolders, it is essential to use some method to find user and system folders
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width