Running CMD as administrator with an argument from C#

后端 未结 5 2195
一向
一向 2020-12-10 16:54

I want to run cmd.exe as administrator with arguments from C# in order to prevent a UAC popup. This is necessary in order to use it as an automated installation

5条回答
  •  难免孤独
    2020-12-10 17:43

    Two solutions: First, you may the user's appdata directory. This will save you from needing admin privileges in the first place. (in a more general approach - think carefully if you really need those privileges)

    Another solution us creating a Windows service which would have those privileges. The first installation of that service would require admin privileges, but after that, you can delegate your work to that service.

    The second solution is a potentially security breach - so you'll have to think about what that service would be able to do carefully.

提交回复
热议问题