Jump to content

NTFSLink (Junction)


g_BonE
 Share

Recommended Posts

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...
Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...