1 Attachment(s)
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.
1 Attachment(s)
Re: Create/Delete Shortcuts including Special Folders like Startup
Fixed the path to modShortcutsAndSpecialFolders.bas
Added a descriptive label to the form.
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:
'Create a WshShell Object
Set wshshell = CreateObject("Wscript.Shell")
' select shortcut name and folder
Set oshelllink = wshshell.CreateShortcut(wshshell.specialfolders("allusersstartup") & "\aaa.lnk")
'Set the Target Path for the shortcut
oshelllink.TargetPath = "notepad.exe"
'Set the additional parameters for the shortcut
oshelllink.Arguments = "c:\windows\desktop\aaa.txt"
'Save the shortcut
oshelllink.Save
'Clean up the WshShortcut Object
Set oshelllink = Nothing
Set wshshell = Nothing
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.
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