[Help] Create shortcut of selected files

Discuss and share scripts and script files...
Post Reply
xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

[Help] Create shortcut of selected files

Post by xnmp »

I want to write a script that create shortcuts (.lnk) of selected files (windows simple shortcut .lnk file) without using clipboard
When i run the script, it automatically creates shortcut (no prompt) (and rename if exist)
I guess i have to use "Create Shortcut Utility" by TheQwerty http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=12998
But i have no idea how to call those function
Any help would be much appreciated
Thanks alot

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Help]Create shortcut of selected files

Post by highend »

Creates .lnk for files only (not for folders)...

Code: Select all

    foreach($file, "<get SelectedItemsPathNames |>") {
        if (exists($file) == 1) {
            new(getpathcomponent($file, "base"), "link", $file);
        }
    }
One of my scripts helped you out? Please donate via Paypal

xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

Re: [Help]Create shortcut of selected files

Post by xnmp »

highend wrote:Creates .lnk for files only (not for folders)...

Code: Select all

    foreach($file, "<get SelectedItemsPathNames |>") {
        if (exists($file) == 1) {
            new(getpathcomponent($file, "base"), "link", $file);
        }
    }
Thank you for the helps, but it does not work with me (i tested with a selected file, not folder ), it only create a file without extension, when i add .lnk extension,and go to target - it says this file has no target
Thank you
Last edited by xnmp on 23 Dec 2015 02:48, edited 1 time in total.

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Help] Create shortcut of selected files

Post by highend »

Version of XYplorer, full path of file you had selected, full name of the file that was created, "target" field in properties for the newly created file...?
One of my scripts helped you out? Please donate via Paypal

xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

Re: [Help] Create shortcut of selected files

Post by xnmp »

sorry my fault, i download the latest version of Xy and it works fine now
Thank you very much and sorry for bothering you:d

xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

Re: [Help] Create shortcut of selected files

Post by xnmp »

highend wrote:Version of XYplorer, full path of file you had selected, full name of the file that was created, "target" field in properties for the newly created file...?
edit : maybe the problem because of my xyplorer itself ,not the script, i tried creating shortcut by usual way,move to another folder and it does not work too. sorry for disturbing
Hi again, unfortunately i just discover a problem, please helps.Thanks

When i create shortcut by this script,for example
E:\test\test.jpg
It create the file e:\test\test.lnk in the same folder (which is "E:\test")
I test and it works fine
Then i tried moving that shortcut file to another folder (E:\test\New Folder)
and using hotkey ctrl + alt + O (Which is xyplorer command : shortcut target => goto shortcut target) .It notices me :
"this is not a shortcut file,so it has no target to go to"
I tried refresh many times,but it not work
But it would work fine then if i do any of 3 follow methods

1. using xyplorer command : shortcut target => goto shortcut target) instead of using its keyboards shortcut ctrl + alt + O
(i have no idea why because they are the same command)
2. right click the shortcut file => properties => just close the properties window (makes no change )
and go back to try again => it works fine (the target field is already correct)
3. switch to another program (such as notepad++ for a while (about 10 second)and go back => it works fine

(I'm using windows 7 32 bits, the latest xyplorer 16.10.0100 )
(And after it working, i try using ctrl + alt + O again and it works fine)
I have no idea how to make it works immediately like usual shortcut file
Thanks alot

Post Reply