Link to home
Start Free TrialLog in
Avatar of Mik Mak
Mik Mak

asked on

Create desktop shortcut in VBA, with startup parameter/argument

In Access 2010/2013/2016 I'm using a function to create a desktop shortcut for a database - but I need to also supply a "/cmd" argument to do some detection when starting up the database - the parameter is put in the shortcut, but is ignored when starting up the database

Set scr = CreateObject("WScript.Shell")
Set scrLink = scr.CreateShortcut(strPath)
scrLink.TargetPath = scPath
scrLink.Arguments = "/cmd " & cmdPath
scrLink.IconLocation = iconPath
scrLink.Save

Open in new window

Avatar of George Walton
George Walton
Flag of United Kingdom of Great Britain and Northern Ireland image

Execute your code and check the ShortCut, is it correct cmd line ? change it manually , will it work after that?

Perhaps you have problem in ShortCut text or in VB code
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mik Mak
Mik Mak

ASKER

Hi als315 - I think you're quite right that it needs a program path to transfer the parameter - but if a program path needs to be included how can I make the shortcut function work across different installations ?
Avatar of Mik Mak

ASKER

I can use SysCmd(acSysCmdAccessDir) :)