C#以管理员用户打开某个程序

        static void Main(string[] args)
        {
              string path = @"C:\Windows\AppPatch\AppLoc.exe";
            ProcessStartInfo P = new ProcessStartInfo();
            P.FileName = path;
            P.UserName = "administrator";
           
             System.Security.SecureString ss = new System.Security.SecureString();
            ss.AppendChar('s');
            ss.AppendChar('1');
            ss.AppendChar('2');
            ss.AppendChar('3');
            ss.AppendChar('3');
            ss.AppendChar('3');
            
            P.Password = ss;
            P.UseShellExecute = false;
            P.StandardOutputEncoding = Encoding.UTF8;
            Process.Start(P);
           
               // System.Diagnostics.Process.Start(@"D:\Program Files\1\InputEasy.exe",{ Verb = "runas" });
            // string path = @"D:\Program Files\1\InputEasy.exe";
           //  string path = @"C:\Windows\AppPatch\AppLoc.exe";
              //string userName, SecureString password, string domain
              //Process.Start(new ProcessStartInfo(path) { Verb = "runas" });


           //  Process.Start(path, @"Administrator", ss, "yuming");
     

        }

 

posted on 2016-09-23 08:47  愚公学编程  阅读(426)  评论(0编辑  收藏  举报