Often people have to run things as an Administrator or as other permissions. This program does just that. It runs in resident memory, and allows you to run various file extensions as a different user. The use shell execute has to be set as "false" unless you are running as the current user. In which case you'd have to sans the username/password.
34 SecureString password = new SecureString();
35 foreach (char c in "password".ToCharArray())
36 password.AppendChar(c);
37
38
39 ProcessStartInfo procInfo = new ProcessStartInfo();
40
41 procInfo.UseShellExecute = false;
42 procInfo.UserName = "adminaccount";
43
44 procInfo.FileName = XRun; //The file in that DIR.
45 procInfo.Password = password; //The file in that DIR.
46
47 procInfo.WorkingDirectory = @""; //The working DIR.
48
49 //procInfo.Verb = "runas";
50
51 Process.Start(procInfo); //Start that process.
52
53
54
55 ntyEP.ShowBalloonTip(
56 5000,
57 AppTitle,
58 XRun + " has been run!",
59 ToolTipIcon.Warning);
35 foreach (char c in "password".ToCharArray())
36 password.AppendChar(c);
37
38
39 ProcessStartInfo procInfo = new ProcessStartInfo();
40
41 procInfo.UseShellExecute = false;
42 procInfo.UserName = "adminaccount";
43
44 procInfo.FileName = XRun; //The file in that DIR.
45 procInfo.Password = password; //The file in that DIR.
46
47 procInfo.WorkingDirectory = @""; //The working DIR.
48
49 //procInfo.Verb = "runas";
50
51 Process.Start(procInfo); //Start that process.
52
53
54
55 ntyEP.ShowBalloonTip(
56 5000,
57 AppTitle,
58 XRun + " has been run!",
59 ToolTipIcon.Warning);
No comments:
Post a Comment