This is Test Application which can be used to recycle the IIS App Pools of the server. In this app I have given only one server but you can give any no of servers you want just add the buttons and copy the code of the button "button_Server_Click" to the other button code's. Also you can add any no. of apppools you want.
Using the code
This is a test Application .In this Application I have used WMIC Code to recycle the AppPools of the server .The code to recycle the Apppool is written in button click event "button_Server_Click"
string command = String.Empty;
command = "wmic /namespace:" + "\"\\\\root/MicrosoftIISv2\"" + " /node:" + " \"Your_ Server_Name\" " + "path IISApplicationPool where (name like '%Your_IISAppool1%') call recycle";
ExecuteCmd cmd = new ExecuteCmd(); cmd.ExecuteCommandAsync(command);
public void ExecuteCommandAsync(string command)
Thread objThread = new Thread(new ParameterizedThreadStart(ExecuteCommandSync));
objThread.IsBackground = true;
objThread.Priority = ThreadPriority.AboveNormal;
catch (ThreadStartException objException)
catch (ThreadAbortException objException)
catch (Exception objException)
Here the main code is "wmic /namespace:" + "\"\\\\root/MicrosoftIISv2\"" + " /node:" + " \"%Your_ Server_Name%\" " + "path IISApplicationPool where (name like '%Your_IISAppool1%') call recycle";"
In"% Your_Server_Name%" :- Give the name of the server whose apppool you want to recycle.
In" %Your_IISAppool1%" :- Give the name of IIS apppool of the server you want to recycle.
Point to be noted:- All the server should be in same network.