Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
230 views
Welcome To Ask or Share your Answers For Others

1 Answer

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();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...