?
Solved

VB Script to make a shortcut to access database

Posted on 2012-03-27
2
Medium Priority
?
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
plummet earned 2000 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Here's a look at newsworthy articles and community happenings during the last month.
Let's recap what we learned from yesterday's Skyport Systems webinar.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 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