0

I have created one button and on click of button I want to reset my IIS from command prompt in background..

This is how I tried:

namespace Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var psi = new ProcessStartInfo
            {
                FileName = "cmd",
                WindowStyle = ProcessWindowStyle.Hidden,
                UseShellExecute = false,
                CreateNoWindow = true,
                Arguments = @" /C IISRESET"
            };
            Process.Start(psi);
        }
    }
}

It seems like not working. What should be the correct way? I'm Very new in this. Any suggestion would be appreciated.

Raj
  • 9
  • 6
  • 1
    `/C`, not `/ C` (check the space) – Cid Aug 18 '20 at 07:44
  • ok.. I will correct that.. Rest code is correct ??@Cid – Raj Aug 18 '20 at 07:47
  • 1
    I think this will need to run with admin rights to work (someone correct me if I'm wrong!). Also, if you're using IIS7 or later there's a managed interface for this so you don't *have* to run an EXE to do it; see [this answer](https://stackoverflow.com/a/4959268/106159) for details. – Matthew Watson Aug 18 '20 at 07:50

0 Answers0