Configure a shortcut file programmatically?

  • Thread starter Thread starter David Portwood
  • Start date Start date
D

David Portwood

Under program control, I want to change the paths to point to a database on
the user's local drive. From within Access, does anybody know how to do
this?
 
I don't want to create a shortcut. I have a dummy shortcut file (.lnk). I
need to change the paths in the dummy file.

I want to code an "Install.mdb" file. When the user opens Install.mdb, an
Autoexec macro will copy the main application database and a version checker
database from a shared network drive to the user's local drive. Among the
copied files will be the dummy shortcut file.

I can get the user's My Documents folder, which is where the applications
will go. I can also get the location of his Desktop folder, which is where
the shortcut will go. All of this from the CurDir() function.

I have copies of all the files, including the shortcut file, stored in a
Download folder on the net. It is an easy matter to copy the files to the
user's local folders. I've got this part working. All that's left is to
update the paths in the shortcut file and then my app will be installed
locally on the user's machine. All the user has to do to make this happen is
double-click the Install database.

But I still need to learn how to reconfigure the shortcut file
programmatically.
 
I have copies of all the files, including the shortcut file, stored in a
Download folder on the net. It is an easy matter to copy the files to the
user's local folders. I've got this part working. All that's left is to
update the paths in the shortcut file and then my app will be installed
locally on the user's machine. All the user has to do to make this happen is
double-click the Install database.

One way to do this is to not store the paths in the shortcut at all - use
symbols instead! Instead of C:/Program Files/ you can use %programfiles%,
instead of C:\Windows use %systemroot% and so on. You can use a DOS SET
command to define these - or use it without arguments to see what standard
symbols are already defined.

John W. Vinson [MVP]
 
David Portwood said:
Under program control, I want to change the paths to point to a database on
the user's local drive. From within Access, does anybody know how to do
this?

I can't recall exactly but I'm pretty sure that if you run the
following code if the shortcut needs to be updated it will be updated
and if it needs to be created it will also be created.

SHGetSpecialFolderLocation: Create a Desktop Shortcut
http://vbnet.mvps.org/index.html?code/shell/desktoplink.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Most of what y'all are telling me is over my head. I was hoping I could
(somehow) attach a variable to the existing shortcut, set a few properties,
and then badda bing, badda boom, done!

Douglas' code looks very close to what I'm looking for - except it involves
creating a shortcut. That may be ok and I may end up doing that, but it
seems like a complication that I shouldn't have to deal with.
 
A shortcut is simply a file (with an extension of .lnk). Deleting the
existing shortcut and creating a new one is probably the easiest approach.
 
Creating the shortcut, rather than copying and modifying an existing one, is
beginning to sound like a cleaner approach. I won't have to "carry" a dummy
file copy in my Download folder.

I'll try it on Monday. Thanks for the help, Doug. Thanks to all who took the
time to think about the problem and respond.
 
Doug, your shortcut creation code worked wonderfully! "Slicker than snot on
a doorknob!", as my Grandma used to say. It is very simple, straightforward
code which even a mug like me can understand.

I was reading through the other articles that you wrote for that Access
magazine. IMHO, it is all very valuable information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top