Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Folder2Junction: Moves Folder and Makes a NTFS Junction


  • Please log in to reply
15 replies to this topic
instantrunoff
  • Members
  • 115 posts
  • Last active: Oct 10 2011 07:19 PM
  • Joined: 13 Jan 2008
Folder2Junction 1.0

Updated 2008/Apr/5

Requirements: Windows Vista or higher (uses mklink command which is new to Vista). Can be used only on NTFS disks.

Description: Moves a folder to a new location, then makes a NTFS junction in the folder's original location pointing to its new location. NTFS junctions are like wormholes in the file system. Folder2Junction was created so that it would be easier to move sensitive files to an encrypted disk (for example, using TrueCrypt) while keeping junctions in the files' original unencrypted location to maintain ease-of-access and compatibility with applications.

Screenshot:

Posted Image

Cautions: Junction points are kind of a bizarre feature, and there may be strange or bad effects if used inappropriately. I encourage you to learn more about NTFS junctions before using this or similar utilities. Making junctions within junctions may be especially hazardous. Folder2Junction attempts a few safeguards: it will try to not let you move a "folder" that is already actually a junction; it will also refuse to move a folder to a location that already contains a folder of the same name; and it will verify the formation of a junction in the original location. If there is a problem with junction creation, Folder2Junction will ofter to move the folder back to its original location.

For more information about junctions and NTFS, there's a decent article on Wikipedia: <!-- m -->http://en.wikipedia...._junction_point<!-- m -->

For more on TrueCrypt (not affilated with Folder2Junction): <!-- m -->http://www.truecrypt.org<!-- m -->

Folder2Junction thread on the AutoHotkey forum: <!-- m -->http://www.autohotke...topic30402.html<!-- m -->

Acknowledgements: Created with AutoHotkey, Compile_AHK II, and Inno Setup, which are awesome. Icon is a squished version "Copy" by Kelli Shaver: <!-- m -->http://DesignMagus.com<!-- m --> Thanks too to converticon.com and IcoFX. Additional acknowledgements to Lexikos and many others on the AutoHotKey forum for teaching me about AHK, and to Hermann Schinagl for his Link Shell Extension and website that helped me learn more about hard links. If you want to do more with NTFS links or on earlier versions of NT-based Windows, his utility is very good and also free. Additional thanks to the makers of AutoHotkey and for providing autohotkey.net for hosting scripts like Folder2Junction. I'd like to also acknowledge all the software developers who make freeware; I've really appreciated it, and I'm glad I can for the first time contribute a freeware program of my own.

AutoHotkey: <!-- m -->http://www.autohotkey.com<!-- m -->
Compile_AHK II: <!-- m -->http://www.autohotke...topic22975.html<!-- m -->
Inno Setup: <!-- m -->http://www.jrsoftware.org/isinfo.php<!-- m -->
Link Shell Extension: <!-- m -->http://schinagl.priv... ... llext.html<!-- m -->

Download Setup

Source (Source is also included with the setup package)

This is my first utility for Windows ever! If you have any advice, please let me know. I hope this is useful to somebody.

instantrunoff
  • Members
  • 115 posts
  • Last active: Oct 10 2011 07:19 PM
  • Joined: 13 Jan 2008
2008/April/5

Updated description and made script more robust. Changed version number to 1.0, because it does everything I want it to do and version 0.2 sounded too unfinished.

Thanks.

instantrunoff
  • Members
  • 115 posts
  • Last active: Oct 10 2011 07:19 PM
  • Joined: 13 Jan 2008
download link fixed

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
This looks terrific (and well documented), but I am afraid of trying it in my main PC. I wait to see if others burn their fingers with it...

Superfraggle
  • Members
  • 1019 posts
  • Last active: Sep 25 2011 01:06 AM
  • Joined: 02 Nov 2004
There is a tool in the win2000 powertools, you could include to add support for XP and 2000, or alternatively.

<!-- m -->http://www.microsoft... ... ction.mspx<!-- m -->
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle

instantrunoff
  • Members
  • 115 posts
  • Last active: Oct 10 2011 07:19 PM
  • Joined: 13 Jan 2008
Thanks for your support! About making it work on Windows XP/2000, I thought of employing Junction.exe by Sysinternals instead of the Vista-specific command mklink, but I was worried that people might have accidental deletes and the like too readily, because those versions of Windows, unlike Vista, do not have a junction-aware Explorer. Like I wrote here, when a junction is deleted in Vista's default shell, the target is untouched. Also, junctions in Vista have a telltale icon overlay, whereas they look identical to regular folders in XP. I believe that deleting a junction in Explorer under XP deletes the original folder.

The Link Shell Extension I mention above does have XP/2000 support, but the extension itself provides an icon overlay for pre-Vista Windows so the user can tell what's what. Further, the Link Shell Extension prevents accidental deletion:

Junctions can be deleted by using the Delete commands from Explorer as usual, if Link Shell Extension is installed, because Link Shell Extension implements a so called CopyHook handler, which intercepts Explorers Delete commands, and thus fixes Explorers problems with junctions.


I'd be more willing to add support for XP/2000 if someone could help me figure out how to provide the icon overlay and a CopyHook handler like this other program, especially since Folder2Junction might be useful only to those now who have Vista without EFS (Home Basic and Home Premium) and are savvy enough to understand NTFS junctions.

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
this is your 'method':
RunWait, %comspec% /c mklink /j "%A_LoopFileName%" "%folderdestination%\%A_LoopFileName%", %A_LoopFileDir%


which obviously not work in XP, and could be done just by RUN direct from Vista....


just in case anyone actually works out DLL calls to actually CREATE junctions by AHK (vs. wrap command line).
Joyce Jamce

instantrunoff
  • Members
  • 115 posts
  • Last active: Oct 10 2011 07:19 PM
  • Joined: 13 Jan 2008

this is your 'method':

RunWait, %comspec% /c mklink /j "%A_LoopFileName%" "%folderdestination%\%A_LoopFileName%", %A_LoopFileDir%


which obviously not work in XP, and could be done just by RUN direct from Vista....


just in case anyone actually works out DLL calls to actually CREATE junctions by AHK (vs. wrap command line).


Sorry you don't like it. Perhaps another software would be better suited for you.

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006

Sorry you don't like it. Perhaps another software would be better suited for you.


not an issue of like. Looks very nice from the screenshot, and nothing wrong with your nice code.


Would be nice if there actually were some work on AHK Folder2Junction. You've done what looks like a super nice job of wrapping the command line (which is something AHK does great & obviously you took a lot of time etc.).


worth keeping clear what this is... Vista command line wrapper, essentially...
Joyce Jamce

instantrunoff
  • Members
  • 115 posts
  • Last active: Oct 10 2011 07:19 PM
  • Joined: 13 Jan 2008
This might interest you: <!-- m -->http://www.autohotke... ... highlight=<!-- m -->

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
<!-- m -->http://www.totalcmd..../ntfslinks.html<!-- m -->

This program allows to create hard links and junctions on NTFS volumes

I am very happy with this program, I am using it for years. It works on each system I tried.

Although its among Total Commander utilities it can be used without it.

How to use it:
NtfsLinks.exe <ListOfFiles.txt> <DestinationFolder> /i=NL_Eng.ini

Each file in the list of files is on the separate line with full path.
Posted Image

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
some cool stuff could be done with an AHK based control for junctions. Once had looked to do that, and realized was going to take way longer to build than had to devote to proj.

Was all excited that someone had actually been able to work thru all the web of steps and built an AHK junction box...

but alas,

command line wrapper for Vista....

such is life...

(somehow missed the "
Requirements: Windows Vista or higher (uses mklink command which is new to Vista). Can be used only on NTFS disks. " in description... sorry...)
Joyce Jamce

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006

This might interest you: <!-- m -->http://www.autohotke... ... highlight=<!-- m -->


yes, nice.


but what about trying to figure out if a folder HAS a junction (vs. *is* a junction).
Joyce Jamce

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
Junction point can be handled natively with AHK. Here is a quote of myself more than a year ago in the thread:
<!-- m -->http://www.autohotke...ic22862-15.html<!-- m -->

If Vista, I think you can use CreateSymbolicLink API, but I can't tell for sure as I have no access to Vista.
If other OS >= W2K, you have to use DeviceIoControl API with FSCTL_SET_REPARSE_POINT/FSCTL_GET_REPARSE_POINT/FSCTL_DELETE_REPARSE_POINT.

Here is a reference in MSDN:
<!-- m -->http://msdn.microsof...y/aa363948.aspx<!-- m -->

Curiously no one seems to have tried implementing it. Or someone had tried but failed? I'd not be surprised to hear that as the MSDN documentation is incorrect or incomplete. However, all needed ones are already there, so it's just a matter of putting them properly.

tuatara
  • Members
  • 1 posts
  • Last active:
  • Joined: 10 Aug 2013

Hi!

 

I would like to download Folder2Junction. Please let me know where to get it - I found only 2 possibilities in the WEB infected by a trojan.

 

Thanks'