I would like to quickly be able to check whether a site is online after logging into the desktop of Windows Server 2008 R2 (x64). I would prefer to be able to do this in just 1 single or double-click (or better yet, without clicking at all) than to have to navigate the tree structure of the IIS Manager.
I can make a shortcut to IIS Manager and put it on my desktop, but how do I force it to open to the SERVERNAME/Sites view rather than clicking several times to get there?
If it can't be done, is there some other way without doing programming that I can put an "online/offline" indicator (preferably in the system tray or on the desktop) for each site I want to put there?
If I have to resort to programming for this seemingly simple feature, how can I get the status (started or stopped) for a specific IIS web site to be shown in my custom program? What API, file, or registry entry do I need to read to get this status info?
I discovered someone else with a .bat file that used the appcmd.exe IIS utility. After some trial and error after reading the MSDN documents about the appcmd.exe utility, I was able to piece together the following .bat file that does the job nicely. The task at hand was simply to get a site (or multiple site's) state in 2 clicks or less from the desktop.
@echo off :Status Set STATUS1=MAINTENANCE FOR /F "tokens=*" %%A IN ('%SystemRoot%\System32\inetsrv\appcmd list site /site.name:www.mysite1.com /text:state ^| FIND "Started"') DO SET STATUS1=STARTED Set STATUS2=MAINTENANCE FOR /F "tokens=*" %%A IN ('%SystemRoot%\System32\inetsrv\appcmd list site /site.name:www.mysite2.com /text:state ^| FIND "Started"') DO SET STATUS2=STARTED echo www.mysite1.com: %STATUS1% echo www.mysite2.com: %STATUS2% pause
Unfortunately, the utility is not documented very well - I had to tinker with it quite a bit to get the result I wanted.
%SystemRoot%\System32\inetsrv\appcmd list site /site.name:www.mysite1.com
This is the line that gets the status, but running it like this returns a bunch of other stuff too. So, in order to just get the status and nothing else, another parameter must be added.
%SystemRoot%\System32\inetsrv\appcmd list site /site.name:www.mysite1.com /text:state
Following the example in the link, I was also able to put together a menu to instantly start and stop the sites by pressing a key and then ENTER, and then it displays the status of the sites again - all from one .bat file.