How to get the target of a connection or Symlink with a standard user

I am trying to get the connection target in my program, but the only way I did this is:

  • Request backup privileges
  • p-invoke CreateFile with special parameters to get the / dir file descriptor.
  • Request DeviceIoControl to get the target.

The first step will not work with regular user accounts, because they do not have backup privileges, and I do not want to receive a UAC user consent window every time I do this.

I think this can be done anyway, because the normal command "dir / A: L" resolves the target of the links.

+3
source share
1 answer

I think this answer in stackoverflow will help you? How to programmatically access the target path of a Windows symbolic link? It should be possible to include a link to a function through the DllImport attribute in a C # program.

The required descriptor can be obtained from an instance of a FileStream . It is somewhat ridiculous that it is marked as deprecated, but perhaps a warning indicates what else you can do.

0
source

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


All Articles