-1

I have a few commands I want to run through the CMD (admin): ipconfig/flushdns ipconfig /registerdns ipconfig /release ipconfig /renew netsh winsock reset Anyone can tell me how?

Leviathan
  • 31
  • 1
  • 9
  • 1
    Possible duplicate of [Elevating process privilege programmatically?](https://stackoverflow.com/questions/133379/elevating-process-privilege-programmatically) – Vanna Aug 27 '17 at 21:26

2 Answers2

0

If you are looking to use powershell, you can create a script which will include your commands something like this:

& "command 1"; & "command 2"; etc.

Stewie
  • 11
  • 3
0

Question of is sort answered here: Running cmd commands with Administrator rights

The code could be duplicated (as shown below):

 System.Diagnostics.Process process = new System.Diagnostics.Process();
    System.Diagnostics.ProcessStartInfo startInfo = new 
    System.Diagnostics.ProcessStartInfo();
    startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    startInfo.FileName = "cmd.exe";
    startInfo.Arguments = "/C ipconfig /flushdns";
    startInfo.Verb = "runas";
    process.StartInfo = startInfo;
    process.Start();

System.Diagnostics.Process process2 = new System.Diagnostics.Process();
    System.Diagnostics.ProcessStartInfo startInfo2 = new 
    System.Diagnostics.ProcessStartInfo();
    startInfo2.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    startInfo2.FileName = "cmd.exe";
    startInfo2.Arguments = "/C ipconfig /renew";
    startInfo2.Verb = "runas";
    process2.StartInfo = startInfo2;
    process2.Start();
R1CH101
  • 60
  • 8