0

I am trying to make an argument with the following

What i am trying to achieve is once i click on the 'button4', the dns should be flushed and a pop should appear. I am stuck on this. Any help would be appreciated.

        {
            try
            {
                Process.Start(new ProcessStartInfo
                {
                    FileName = "cmd.exe",
                    Arguments = "/c ipconfig / flushdns",
                    WindowStyle = ProcessWindowStyle.Hidden
                });
            }
            catch { }```
SymbaQT
  • 9
  • 3
  • See the code here https://stackoverflow.com/questions/1469764/run-command-prompt-commands – I_Al-thamary Sep 05 '20 at 20:47
  • Thanks! I think i've kind of sorted it but im just trying to get a pop up to appear once the command has been executed and completed :) – SymbaQT Sep 05 '20 at 20:50
  • See this https://www.codeproject.com/Questions/720259/How-to-run-command-prompt-command-and-get-output-i and https://stackoverflow.com/a/59235057/4694757 – I_Al-thamary Sep 05 '20 at 20:53
  • 1
    You haven't stated what the problem is. – Ian Kemp Sep 05 '20 at 21:03
  • It's not much of a problem, i just wanted a pop up to appear once the cmd is executed once the button is clicked. – SymbaQT Sep 05 '20 at 21:13
  • Try to add this `UseShellExecute = false` `RedirectStandardOuput = false` `CreateNoWindow = false` or as the answer mentioned above print the results because it runs in the background. Aso, use `Arguments = "/K ipconfig / flushdns"`. Hope that solves the problem. – I_Al-thamary Sep 06 '20 at 07:03
  • Fix typo. Replace this `"/c ipconfig / flushdns"` with `"/C ipconfig /flushdns"`, to upper case `/C`, and remove redundant space. – aepot Sep 06 '20 at 20:42
  • @i_thamary `/C` - execute and exit, `/K` - execute and stay. That's the difference. – aepot Sep 06 '20 at 20:44
  • Also consider to setup explicitly `UseShellExecute` and `CreateNoWindow` properties for `ProcessStartInfo`. – aepot Sep 06 '20 at 20:49

0 Answers0