Solved

VB Script to make a shortcut to access database

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

777 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