okkko
okkko

Reputation: 1

How to get the path of a shortcut (NOT target path) in .net?

I have an .exe application written in vb.net. When I make shortcuts to the application, say on desktop (or anywhere else) and then click on them I want to programatically get the path to that shortcut, ie. C:/Users/xxx/Desktop/shortcut.lnk.

I want this so I can store the pairs shortcuts : (program + different cmd args).

Upvotes: 0

Views: 2093

Answers (1)

Hans Olsson
Hans Olsson

Reputation: 55059

Your desktop wouldn't be the parent process since it's not a process, I assume explorer or something would be if it's started from a shortcut.

The easiest way to get what you want would be to change the shortcuts to send in some parameter to your app when it starts it. So for example, the shortcut on the desktop could send in the string "desktop". Then you could just pick it up as a normal command line parameter.

If you've declared a Main function as:

Public Shared Sub Main(ByVal args As String())

Then it would appear as one of the strings in the args parameter.

Upvotes: 1

Related Questions