Junction Points

Started by therkilt, June 18, 2014, 08:04:26 AM

Previous topic - Next topic

therkilt

Is there a good way to find Junction point information with WinBatch?

I have a script to identify junction point locations however it pops up cmd windows to do it so I am looking for another way to identify junction point locations.

Windows 7 as a user:
DocumentsandSettings      = C:\Users
AllUsersProfile         = C:\ProgramData
AllUsersDesktop         = C:\Users\Public\Desktop
AllUsersStartMenu      = C:\ProgramData\Microsoft\Windows\Start Menu
AllUsersApplicationData      = C:\ProgramData
AllUsersTemplates      = C:\ProgramData\Microsoft\Windows\Templates
AllUsersDocuments      = C:\Users\Public\Documents
AllUsersFavorites      = C:\Users\Public\Favorites
DefaultUserProfile      = C:\Users\Default
DefaultUserDesktop      = C:\Users\Default\Desktop
DefaultUserStartMenu      = C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu
DefaultUserApplicationData   = C:\Users\Default\AppData\Roaming
DefaultUserTemplates      = C:\Users\Default\AppData\Roaming\Microsoft\Windows\Templates
DefaultUserLocalSettings   = C:\Users\Default\AppData\Local
DefaultUserMyDocuments      = C:\Users\Default\Documents
DefaultUserFavorites      = C:\Users\Default\Favorites
UserProfile         = C:\Users\sdfkj3
UserProfileDesktop      = C:\Users\sdfkj3\Desktop
UserProfileStartMenu      = C:\Users\sdfkj3\AppData\Roaming\Microsoft\Windows\Start Menu
UserProfileApplicationData   = C:\Users\sdfkj3\AppData\Roaming
UserProfileTemplates      = C:\Users\sdfkj3\AppData\Roaming\Microsoft\Windows\Templates
UserProfileNethood      = C:\Users\sdfkj3\AppData\Roaming\Microsoft\Windows\Network Shortcuts
UserProfilePrinthood      = C:\Users\sdfkj3\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
UserProfileLocalSettings   = C:\Users\sdfkj3\AppData\Local
UserProfileMyDocuments      = C:\Users\sdfkj3\Documents
UserProfileFavorites      = C:\Users\sdfkj3\Favorites
ProfilesDir         = C:\Users

Windows 7 as the System Account:
DocumentsandSettings      = C:\Users
AllUsersProfile         = C:\ProgramData
AllUsersDesktop         = C:\Users\Public\Desktop
AllUsersStartMenu      = C:\ProgramData\Microsoft\Windows\Start Menu
AllUsersApplicationData      = C:\ProgramData
AllUsersTemplates      = C:\ProgramData\Microsoft\Windows\Templates
AllUsersDocuments      = C:\Users\Public\Documents
AllUsersFavorites      = C:\Users\Public\Favorites
DefaultUserProfile      = C:\Users\Default
DefaultUserDesktop      = C:\Users\Default\Desktop
DefaultUserStartMenu      = C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu
DefaultUserApplicationData   = C:\Users\Default\AppData\Roaming
DefaultUserTemplates      = C:\Users\Default\AppData\Roaming\Microsoft\Windows\Templates
DefaultUserLocalSettings   = C:\Users\Default\AppData\Local
DefaultUserMyDocuments      = C:\Users\Default\Documents
DefaultUserFavorites      = C:\Users\Default\Favorites
UserProfile         = C:\Windows\system32\config\systemprofile
UserProfileDesktop      = C:\Windows\system32\config\systemprofile\Desktop
UserProfileStartMenu      = C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Start Menu
UserProfileApplicationData   = C:\Windows\system32\config\systemprofile\AppData\Roaming
UserProfileTemplates      = C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Templates
UserProfileNethood      = C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Network Shortcuts
UserProfilePrinthood      = C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
UserProfileLocalSettings   = C:\Windows\system32\config\systemprofile\AppData\Local
UserProfileMyDocuments      = C:\Windows\system32\config\systemprofile\Documents
UserProfileFavorites      = C:\Windows\system32\config\systemprofile\Favorites
ProfilesDir         = C:\Users

Windows XP as a user:
DocumentsandSettings      = C:\Documents and Settings
AllUsersProfile         = C:\Documents and Settings\All Users
AllUsersDesktop         = C:\Documents and Settings\All Users\Desktop
AllUsersStartMenu      = C:\Documents and Settings\All Users\Start Menu
AllUsersApplicationData      = C:\Documents and Settings\All Users\Application Data
AllUsersTemplates      = C:\Documents and Settings\All Users\Templates
AllUsersDocuments      = C:\Documents and Settings\All Users\Documents
AllUsersFavorites      = C:\Documents and Settings\All Users\Favorites
DefaultUserProfile      = C:\Documents and Settings\Default User
DefaultUserDesktop      = C:\Documents and Settings\Default User\Desktop
DefaultUserStartMenu      = C:\Documents and Settings\Default User\Start Menu
DefaultUserApplicationData   = C:\Documents and Settings\Default User\Application Data
DefaultUserTemplates      = C:\Documents and Settings\Default User\Templates
DefaultUserLocalSettings   = C:\Documents and Settings\Default User\Local Settings
DefaultUserMyDocuments      = C:\Documents and Settings\Default User\My Documents
DefaultUserFavorites      = C:\Documents and Settings\Default User\Favorites
UserProfile         = C:\Documents and Settings\sdfkj3
UserProfileDesktop      = C:\Documents and Settings\sdfkj3\Desktop
UserProfileStartMenu      = C:\Documents and Settings\sdfkj3\Start Menu
UserProfileApplicationData   = C:\Documents and Settings\sdfkj3\Application Data
UserProfileTemplates      = C:\Documents and Settings\sdfkj3\Templates
UserProfileNethood      = C:\Documents and Settings\sdfkj3\Nethood
UserProfilePrinthood      = C:\Documents and Settings\sdfkj3\Printhood
UserProfileLocalSettings   = C:\Documents and Settings\sdfkj3\Local Settings
UserProfileMyDocuments      = C:\Documents and Settings\sdfkj3\My Documents
UserProfileFavorites      = C:\Documents and Settings\sdfkj3\Favorites
ProfilesDir         = C:\Documents and Settings

Thanks.

td

You could do something like the following
Code (winbatch) Select


;;; Can be made more efficient if speed is an issue.
#DefineFunction IsReparsePoint(strDir)
   FILE_ATTRIBUTE_REPARSE_POINT  = 1024
   return DllCall("kernel32.dll", long:"GetFileAttributesW", lpwstr:strDir) & FILE_ATTRIBUTE_REPARSE_POINT
#EndFunction


You could use the FAF extender to traverse the directory structure and call the above UDF on each directory.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Deana

Tony, I think the FAFFind function returns duplicate directories when dealing with reparse points. Not sure how the FileSearch Extender deals with reparse points.
Deana F.
Technical Support
Wilson WindowWare Inc.

td

It is not an issue unless a reparse point is part of a circular reference. Circular references are  mistakes and one of the reason why some Windows 7 directories are by default marked as deny access even to admins.  Circular references are an issue for any software that attempts to both traverse a directory structure and not ignore reparse points.  The FAF extender can be set to ignore reparse points but that is not what you want to do when you are intentionally trying to find them.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Here is a quick and dirty modification of one of the examples in the FAF extender's help file the illustrates one way to obtain the directory reparse points under the 'users' directory on a Windows 8 machine. 

Code (winbatch) Select

#DefineFunction IsReparsePoint(strDir)
   return DllCall("Kernel32.dll", long:"GetFileAttributesW", lpwstr:strDir) & 1024
#EndFunction

#DefineFunction DirFind(filehandle, strDir )
   handle = fafOpen(strDir, '*', 11)
   While 1
      sFound = fafFind( handle )
      If sFound == '' Then Break
      if IsReparsePoint(sFound) then FileWrite( filehandle, sFound )
      else DirFind(filehandle, sFound)
   EndWhile
   fafClose( handle )
#EndFunction


AddExtender('WWFAF44I.DLL', 0, 'WWFAF64I.DLL')
outputfile = DirScript():'Reparselist.txt'
filehandle = FileOpen( outputfile, 'Write')

DirFind(filehandle,'c:\users')

FileClose( filehandle )

Run( outputfile, '' )


A list of shell links could be obtained using the extender to search for '.lnk' files.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade