How do I restart the IIS application pools from command line?
You can use the recycle command as mentioned in Recycle an Application Pool on Demand (IIS 7) or use combination of Stop/Start mentioned at Start or Stop an Application Pool (IIS 7). Both have separate sections for command line.
First your terminal should be elevated to have admin permissions.
Assuming that the inetsrv
folder is not mapped on your system, you can do the following:
"%windir%\system32\inetsrv\appcmd" recycle APPPOOL "MyAppPoolName"
This will recycle the application pool with the name MyAppPoolName
so long as it isn't already stopped. If it is, you'll get the error message ERROR ( message:Application pool "MyAppPoolName" is not started. )
.
There's also the good old-fashioned stop-then-start. Again, it will error if you ask it to stop and it's already stopped):
"%windir%\system32\inetsrv\appcmd" stop APPPOOL "MyAppPoolName"
"%windir%\system32\inetsrv\appcmd" start APPPOOL "MyAppPoolName"
If you want a full list of the supported commands on an application pool, you can run the following:
%windir%\system32\inetsrv\appcmd APPPOOL /?
For reference, this will output the following:
Supported commands:
list List application pools
set Configure application pool
add Add new application pool
delete Delete application pool
start Start application pool
stop Stop application pool
recycle Recycle application pool
(To get help for each command use /?, e.g. 'appcmd.exe add site /?'.)