Author Topic: MC.Utils.CreateLink doesn't work?  (Read 17415 times)

khaoos

  • Newbie
  • *
  • Posts: 8
    • View Profile
MC.Utils.CreateLink doesn't work?
« on: January 19, 2015, 16:35:47 »
Hello, Mathias. I can't figure out what I am doing wrong with a custom command. I am trying to make a MC.Utils.CreateLink to create a symlink. I have even tried the most easiest case, for example MC.Utils.CreateLink LNKSRC="D:\1.txt" LNKTRG="D:\2.txt" LNKTYPE=3. Nothing happens. I will be appreciate for any help.
Version of MC is 4.6.2 (build 1804) 64bit
« Last Edit: January 19, 2015, 16:43:15 by khaoos »

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: MC.Utils.CreateLink doesn't work?
« Reply #1 on: January 19, 2015, 18:32:08 »
To create Symlinks you must be admin.
You can add "ASADMIN" and you will get a UAC dialog or you can start MC as admin.

khaoos

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: MC.Utils.CreateLink doesn't work?
« Reply #2 on: January 20, 2015, 13:21:46 »
I am already an admin and mc is started with admin privileges, and I've tried an ASADMIN option too. Nothing works. I only see a confirmation dialog when I set an appropriate option in command (Display confirmation dialog...). Interesting, I don't see a confirmation dialog when I purposely execute a wrong command, for example MC.Utils.CreateLink1, but I see one when give a wrong argument to a proper command, for example ASADMIN1. So I conclude the command is correct. Are options' names for this command correct in documentation? Could you give me a file with a properly working multi-script CreateLink command, so I can try it on my machine?

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 540
  • Old Skull
    • View Profile
Re: MC.Utils.CreateLink doesn't work?
« Reply #3 on: January 20, 2015, 13:49:53 »
Code: [Select]
if ( GetSourcePath() == GetTargetPath() ) return;

@var $sel_files = GetSourceSelectedPaths();
@var $src_file;
@var $lnk_file;
@var $i = 0;

for ( $i = 0; $i < arrayCount( $sel_files ); $i++ )
{
  $src_file = $sel_files[ $i ];
  $lnk_file = GetTargetPath() + PathGetNamePart( $src_file );
  MC.Utils.CreateLink LNKTYPE=1 LNKTRG="{$src_file}" LNKSRC="{$lnk_file}";
}

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: MC.Utils.CreateLink doesn't work?
« Reply #4 on: January 20, 2015, 14:35:35 »
I am already an admin and mc is started with admin privileges, and I've tried an ASADMIN option too. Nothing works. I only see a confirmation dialog when I set an appropriate option in command (Display confirmation dialog...). Interesting, I don't see a confirmation dialog when I purposely execute a wrong command, for example MC.Utils.CreateLink1, but I see one when give a wrong argument to a proper command, for example ASADMIN1. So I conclude the command is correct. Are options' names for this command correct in documentation? Could you give me a file with a properly working multi-script CreateLink command, so I can try it on my machine?

Works for me.  Sure you have not mixed up SRC and TARGET ?

MC.Utils.CreateLink LNKSRC="R:\1.txt" LNKTRG="R:\2.txt" LNKTYPE=3 ASADMIN

1.txt Must not exists..
2.txt exists.
UAC dialog is shown and MCAdmin (Admin helper Process) is starts
SymLink 1.txt is created and points to 2.txt

(Also if you are connected to work domain symlinks can be disabled by admin. and you must have permission for it. and there is a max number of symlinks you can have in a folder..)
« Last Edit: January 20, 2015, 14:44:08 by Mathias (Author) »

khaoos

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: MC.Utils.CreateLink doesn't work?
« Reply #5 on: January 20, 2015, 15:26:17 »
Sure you have not mixed up SRC and TARGET?
Hell, you're genius! :) I have! I should open up dialog of creating links through menu and notice proper terminology but I was sure I was doing right things. Big thanks for your help!