Run process under current user

前端 未结 3 1002
生来不讨喜
生来不讨喜 2021-01-12 03:54

There is \"Setup project\" in VS. During installation I launch another process:

System.Diagnostics.Process process = new System.Diagnostics.Process();
//fill         


        
3条回答
  •  滥情空心
    2021-01-12 04:25

    Use ProcessStartInfo class and its property UserName, then use it as argument for Process.Start static method.

    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
    Process.Start(startInfo);
    

提交回复
热议问题