Checking / Creating a desktop shortcut

I have an Access 2003 database that uses the Sagekey installation wizzard.  The problem is, that when the users run the install, they are not installing an Access database on their PC, just the runtime and registry setup.  The MDE file that they are ultimately loading is on the server, which means you can't use the Sagekey software to generate the shortcut.

My question is this - through VBA can you reliably detect if a the user has the application shortcut on the the desktop?  If not I want it to be created on the fly, which I think I can do.

Any help would be greatly appreciated.
Andy BrownDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

viralypatelCommented:
use the following macro:
http://www.vbaexpress.com/kb/getarticle.php?kb_id=584

It will create a shortcut if it does not exist. If it exists it will just overwrite with the same thing.
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I'd use the Windows Scripting Shell instead:
Dim WSHShell As Object
Set WSHShell = CreateObject("WScript.Shell")

Dim MyShortcut As Object
Dim MyDesktopPath As String

'/ Get the path to the Desktop. If you want to save the shortcut somewhere else
'/ you'd change this path.
MyDesktopPath = WSHShell.SpecialFolders("Desktop")

'/ This actually creates the shortcut object
Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\MyShortcutName.lnk")

MyShortcut.TargetPath = "Full path to your program"
MyShortcut.WorkingDirectory = "Full path to your working directory"
'/ This saves the shortcut
MyShortcut.Save

Set MyShortcut = Nothing
Set WSHShell = Nothing

Open in new window

If you want to include an Icon, use the .IconLocation setting:
MyShortcut.IconLocation = "path to your icon file"

If you want to define how the program opens (i.e. Maximized, Minimized, etc) use the .WindowStyle setting:
MyShortcut.WindowStyle = 4

The value of 4 = "Displays a window in its most recent size and position. The active window remains active."

This comes from the "Running Program" article: http://technet.microsoft.com/en-us/library/ee156605.aspx

TechNet article about "Working With Shortcuts": http://technet.microsoft.com/en-us/library/ee156583.aspx

KB Article about scripting and shortcuts: http://support.microsoft.com/kb/244677

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Note too that the only way to check if a shortcut exists is if you know the name and location of the shortcut. For example, if I wanted to see if a shortcut named MyAccessShortcut.lnk existed on the desktop I could do so, but I couldn't determine if the same shortcut existed on the Start Menu, or in the Program Menu unless i also checked those locations. Also, if Windows has renamed it to MyAccessShortcut2.lnk, then the routine would not locate that one.

In general, it's best to just create the shortcut and let the users decide if they want to keep them. Even the most unsophisticated Windows users know how to delete a shortcut!
0
Andy BrownDeveloperAuthor Commented:
Superb - that works a treat.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

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.