var gt = txt_gateway.text; System.IO.StreamWriter SW = new System.IO.StreamWriter("route.bat"); SW.WriteLine("route add 88.88.88.88 \"" + gt + "\""); SW.WriteLine("route add 89.89.89.89 \"" + gt + "\""); SW.Flush(); SW.Close(); SW.Dispose(); SW = null;
route.bat
ProcessStartInfo sti = new ProcessStartInfo(); sti.FileName = "myScript.bat"; sti.Verb = "runas"; Process.Start(sti);
ProcessStartInfo psi = new ProcessStartInfo(); psi.WorkingDirectory = "C:\\Diego\\PublishCore"; // psi.CreateNoWindow = true; psi.FileName = @"cmd.exe"; psi.Arguments = "/c start /wait " + "C:\\Diego\\PublishCore\\Startup_InomCore.bat"; // psi.UseShellExecute = true; psi.Verb = "runas"; var process = Process.Start(psi);
Quote:See here: UAC Elevation in Managed Code: Starting Elevated Processes[^]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)