Solved

VB Script to make a shortcut to access database

Posted on 2012-03-27
2
257 Views
Last Modified: 2012-06-11
Hi,

I'm trying to make a VBScript that will generate a link to an access database so i can then deploy this to all machines by GPO. So far I have the following code:

Dim FileName
	FileName = "MyShortcut"
		Set shortcut = CreateObject("WScript.Shell").CreateShortcut(CreateObject("WScript.Shell").SpecialFolders("Desktop") & + "\" + FileName + ".lnk")
			shortcut.Description = "My shortcut"
			shortcut.TargetPath = "C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE" & "\\adminserver\data$\tt6\Register.mdb"
			shortcut.Save

Open in new window


The Shortcut target path works if I generate the shortcut manually by right clicking but the code wont run, I suspect because of quote marks. Help appreciated!

Lans-ICT
0
Comment
Question by:Lans-ICT
2 Comments
 
LVL 10

Accepted Solution

by:
plummet earned 500 total points
ID: 37771773
Hi Lans

Give this a try:

Dim FileName
dim Shortcut
dim oShell

FileName = "MyShortcut"

Set oShell = CreateObject("WScript.Shell")

set Shortcut = oShell.CreateShortcut(oShell.SpecialFolders("Desktop") &  "\" & FileName & ".lnk")
Shortcut.Description = "My shortcut"
Shortcut.TargetPath = "C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE " & "\\adminserver\data$\tt6\Register.mdb"
Shortcut.Save
                                  

Open in new window


Hope it helps. You had a few errors in there but were going in the right direction!
0
 

Author Closing Comment

by:Lans-ICT
ID: 38069407
Thanks for that, it worked!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
My experience with Windows 10 over a one year period and suggestions for smooth operation
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now