How can I make a batch file if the directory is really a connection?

I am writing a batch file (.bat) and I could not find a way to find out if the given directory has a path to the real directory or connection (created in Windows 7 using mklink /j ). Can someone point me in the right direction?

+4
source share
3 answers

This is a lousy technique, but the path to the fsutil reparsepoint query file will not be executed ( %ERRORLEVEL% will be 1) if the file is not a connection and will fail ( %ERRORLEVEL% will be 0) if it is one. Another problem with this: fsutil wants you to be an administrator. In addition, not all reprocessing points are directory intersections.

0
source

In a script package, you can use the following:

  SET Z=&& FOR %%A IN (linkfilename) DO SET Z=%%~aA IF "%Z:~8,1%" == "l" GOTO :IT_A_LINK 

it is faster than calling DIR /AL .

%%~aA gets the "linkfilename" attributes,
string 9 char, for example d-------- (directory),
or d-------l directory link,
or --------l link to the file.

%Z:~8,1% then captures only the reprocessing point attribute.

+9
source

I have this little pearl that will list all the Junctions and their goals in your current directory:

 for /F "delims=;" %j in ('dir /al /b') do @for /F "delims=[] tokens=2" %t in ('dir /a ^| findstr /C:"%j"') do @echo %j :: %t 

Output Example:

 Application Data :: C:\Users\AB029076\AppData\Roaming Cookies :: C:\Users\AB029076\AppData\Roaming\Microsoft\Windows\Cookies Local Settings :: C:\Users\AB029076\AppData\Local My Documents :: C:\Users\AB029076\Documents NetHood :: C:\Users\AB029076\AppData\Roaming\Microsoft\Windows\Network Shortcuts PrintHood :: C:\Users\AB029076\AppData\Roaming\Microsoft\Windows\Printer Shortcuts Recent :: C:\Users\AB029076\AppData\Roaming\Microsoft\Windows\Recent SendTo :: C:\Users\AB029076\AppData\Roaming\Microsoft\Windows\SendTo Start Menu :: C:\Users\AB029076\AppData\Roaming\Microsoft\Windows\Start Menu Templates :: C:\Users\AB029076\AppData\Roaming\Microsoft\Windows\Templates TestLink :: C:\Users\AB029076\AppData\Roaming\Microsoft\Windows\Network Shortcuts 
+2
source

Source: https://habr.com/ru/post/1337686/


All Articles