Sign in to follow this  
Followers 0
g_BonE

NTFSLink (Junction)

2 posts in this topic

hi there,

i know i can create a NTFS junction via:

If Not FileExists('C:\test1junc\') Then
    MsgBox(0, "", FileCreateNTFSLink("C:\test1\", "C:\test1junc\"),1)
EndIf

now, how can i remove this junction ? If usingt FileDelete() i end up deleting both the folders (junction and source) :D , also overwriting the junction with an empty target wont work.

Regards,

g_


...Fenster fährt mich Nüsse...

Share this post


Link to post
Share on other sites



hi there,

i know i can create a NTFS junction via:

If Not FileExists('C:\test1junc\') Then
    MsgBox(0, "", FileCreateNTFSLink("C:\test1\", "C:\test1junc\"),1)
EndIf

now, how can i remove this junction ? If usingt FileDelete() i end up deleting both the folders (junction and source) :D , also overwriting the junction with an empty target wont work.

Regards,

g_

Since it is a directory link, you can use DirRemove(), but DON'T USE THE RECURSE FLAG:

; Note it is critical to NOT recurse!
DirRemove("C:\test1junc\", 0)

Another thing is this can confuse an open instance of Explorer. It may continue to show invalid paths in the destination. Closing it and reopening a new instance of Explorer should resolve it.

Links to a file are easier, just FileDelete() the destination (not the source), and the link is gone.

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
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
Sign in to follow this  
Followers 0