Replace Current Windows User Running the EXE with another user

前端 未结 4 1435
醉话见心
醉话见心 2021-01-16 06:44

Say if I built a windows application that reads files from a network folder. The network folds restrict the access to only one user \"fooUser\". The application is installed

4条回答
  •  温柔的废话
    2021-01-16 07:06

    You could just set up a mapped drive to the folder share that uses the 'fooUser' credentials.

    Though if you have the login/password for the user you can get your code to use impersonation. As per my answer to Windows Impersonation from C# :

    For the Impersonation code see the following two Code Project articles:

    http://www.codeproject.com/KB/cs/cpimpersonation1.aspx

    http://www.codeproject.com/KB/cs/zetaimpersonator.aspx

    and the Microsoft KB article they are based upon:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158

提交回复
热议问题