Jump to content

Get path to compiled script shortcut possible?


Recommended Posts

Hi experts,

I am trying to create a really simple script to place in my IE's Favorites Bar (aka Links) to enable explore the folder.

It is just a simple line as follows:

Run("explorer.exe /e, " & Chr(34) & @WorkingDir & Chr(34))

The compiled script is in c:\scripts, but the shortcut to it is in "C:\Users\<username>\Favorites\Links\AutoIt Links" folder.

The shortcut properties has empty "Start in" textbox.

The problem is that @WorkingDir returns the shortcut's current directory perfectly when running the shourtcut directly from "C:\Users\<username>\Favorites\Links\AutoIt Links" folder, but returns the Desktop path when running from IE.

Changing the shortcut properties, while works, is not an option, as I want to be able to just copy and paste the shortcut around other folders without need to change it, and keep it working even if I rename the folder or change its hierarchy.

It does not work using "." (returns %systemroot%\system32 :?) or "%cd%" in shortcut properties.

So now I am trying to get the shourcut's path so use that path instead of @WorkingDir macro.

There are macros to get compiled script EXE and such... but how can I get the LNK path to the actual compiled script?

Thanks in advance!

Thanks for reading :unsure:

Link to comment
Share on other sites

May be FileGetShortcut function...

Mmmm...

That actually does not work the way I want because it uses the LNK file I want to get the path for.

In other words:

C:\Scripts\MyScript.exe <- This is the compiled script.

C:\Users\<username>\Favorites\Links\AutoIt Links\Explore Here.lnk" is a shourtcut to C:\Scripts\MyScript.exe

What I want is from MyScript.exe get the path of "Explore Here.lnk", wherever it would be.

So as result I want my script to:

C:\Users\<username>\Favorites\Links\AutoIt Links\Explore Here.lnk" run explorer.exe /e, "C:\Users\<username>\Favorites\Links\AutoIt Links"

If I copy "Explore Here.lnk" shortcut to other links bar folder, do the proper work without any further actions:

C:\Users\<username>\Favorites\Links\Other Stuff\Explore Here.lnk" run explorer.exe /e, "C:\Users\<username>\Favorites\Links\Other Stuff"

Thanx for the suggestion though ... :unsure:

Link to comment
Share on other sites

In short: What you want is the path to the calling program / linkfile.

I have no clue how to do this but maybe it helps someone else to solve this.

Perhaps you may find a way to find the process name of the calling program, but from a link file??

:unsure:

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

In short: What you want is the path to the calling program / linkfile.

I have no clue how to do this but maybe it helps someone else to solve this.

Perhaps you may find a way to find the process name of the calling program, but from a link file??

:unsure:

See FileGetShortcut function...

Edit : he wants to know where link is created...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Hi wakillon,

FileGetShortcut will work if you know the calling shortcut - yes. But as far as I understood he has multiple shortcuts to his exe and wants to know which one he has double-clicked to run the exe.

But maybe it would be easier for him to use FileCreateShortcut instead to create the shortcuts by himself. So he can set the WorkingDir correctly.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Hi wakillon,

FileGetShortcut will work if you know the calling shortcut - yes. But as far as I understood he has multiple shortcuts to his exe and wants to know which one he has double-clicked to run the exe.

But maybe it would be easier for him to use FileCreateShortcut instead to create the shortcuts by himself. So he can set the WorkingDir correctly.

Thanks for your replies guys!

However, that is not what I want to do.

The target is being able to do similar behavior to good old "Explore from here" powertoy when you right click on a shell folder.

However, such context menu is not available within IE favorites bar, so I wanted to create a bookmarklet-like thing with this shortcut that "explores" the actual favorites subfolder where the LNK lives.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...