Page 1 of 1

[Help] Create shortcut of selected files

Posted: 22 Dec 2015 17:33
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

Re: [Help]Create shortcut of selected files

Posted: 22 Dec 2015 18:17
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);
        }
    }

Re: [Help]Create shortcut of selected files

Posted: 23 Dec 2015 02:42
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

Re: [Help] Create shortcut of selected files

Posted: 23 Dec 2015 02:48
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...?

Re: [Help] Create shortcut of selected files

Posted: 23 Dec 2015 02:57
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

Re: [Help] Create shortcut of selected files

Posted: 23 Dec 2015 03:28
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