Solved

VB Script to make a shortcut to access database

Posted on 2012-03-27
2
272 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
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…

829 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