Anteaus Posted October 31, 2009 Posted October 31, 2009 There are methods for creating and removing NTFS junctions, but I haven't been able to find a way of identifying that a filesystem-object IS a junction, and not a directory. Any suggestions? (Background is the usual problem with Vista/7 profiles, in that the cyclic junctions in these create problems with enumerating the contents.)
danielkza Posted October 31, 2009 Posted October 31, 2009 From MSDN:These junction points can be identified as follows:They have the FILE_ATTRIBUTE_REPARSE_POINT, FILE_ATTRIBUTE_HIDDEN, and FILE_ATTRIBUTE_SYSTEM file attributes setThey also have their access control lists (ACLs) set to deny read access to everyone.
Anteaus Posted November 1, 2009 Author Posted November 1, 2009 Unfortunately, neither of these provide a definite means of identification. The only defining attribute here (which is not also possessed by some other filesystem objects) is FILE_ATTRIBUTE_REPARSE_POINT - and this doesn't seem to be accessible by any of the normal routes. Anyone got a suggestion as to how to access this property? WMI, maybe? DLL call? Done some poking-around with both but so far got nowhere. There is of course the cowboy method of parsing DIR output -which does work- but I'd rather avoid that if possible.
PsaltyDS Posted November 2, 2009 Posted November 2, 2009 Call Kernel32.dll GetFileAttributes and test the file attributes for FILE_ATTRIBUTE_REPARSE_POINT (0x400). 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
Tlem Posted November 2, 2009 Posted November 2, 2009 It was already discussed here : http://www.autoitscript.com/forum/index.php?showtopic=71756&view=findpost&p=524767 Best Regards.Thierry
PsaltyDS Posted November 2, 2009 Posted November 2, 2009 It was already discussed here : #524767 Nice find, Mhz had already posted a function for this (copied for ease of reference): GetFileAttributes can get the attributes of a symblic link though a flag for detecting a reparse point. The flag also does a symbolic link so not sure of it's accuracy ensuring for certain of symbolic link detection but it tests OK with my brief check with Vista SP1. ; example: returns true if the file is a symbolic link $var = _ReparsePoint('C:\test.txt') MsgBox(0, '', $var) Func _ReparsePoint($string) Local $FILE_ATTRIBUTE_REPARSE_POINT = 0x400 If Not FileExists($string) Then Return SetError(1, 0, '') EndIf $rc = DllCall('kernel32.dll', 'Int', 'GetFileAttributes', 'str', $string) If IsArray($rc) Then If BitAND($rc[0], $FILE_ATTRIBUTE_REPARSE_POINT) = $FILE_ATTRIBUTE_REPARSE_POINT Then Return True EndIf EndIf Return False EndFunc 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now