0

I have a vbscript in "D:\MyDoc\Script\MyScript.vbs" with a shortcut link in "D:\Working\MyScript.vbs.lnk"

By double click the shortcut link, What code can I use to get the location of the shortcut link (ie. "D:\Working\MyScript.vbs.lnk") NOT the target path "D:\MyDoc\Script\MyScript.vbs"

1 Answers1

1

To my knowledge there is no way to get the location of the shortcut that started the script. Although, a shortcut could pass this information to the script. By including the location of the shortcut in the target propery of the shortcut like this:

D:\MyDoc\Script\MyScript.vbs "D:\Working\MyScript.vbs.lnk"

It would be possible to read out the location as a command line argument in the script:

WScript.Echo WScript.Arguments.Item(0)

Although this might not be the original purpose?

alex-dl
  • 802
  • 1
  • 5
  • 12
  • Further to alex-dl answer, is there any way to use "WScript.Echo WScript.Arguments.Item(0)" inside vbscript, or the other way round using vbscript code within WScript batch file. Thanks. – user3660333 Jan 27 '21 at 02:33