Solved

VB Script to make a shortcut to access database

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article outlines the process to identify and resolve account lockout in an Active Directory environment.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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