To check for service status, use the ubiquitous WMI (the code is VBScript, just to give you the idea of the necessary WMI query):
IISrunning = false
wql = "SELECT state FROM Win32_Service WHERE name = 'W3SVC'"
Set w3svc = GetObject("winmgmts://.").ExecQuery(wql)
For Each service in w3svc
IISrunning = (service.State = "Running")
Next
WScript.Echo IISrunning
EDIT: I try and make an IS script out of this. Don't hit me if there is a syntax error.
function BOOL DetectIIS()
OBJECT wmi, slist, obj;
NUMBER i;
BOOL IISrunning;
begin
IISrunning = false;
try
set wmi = CoGetObject( "winmgmts://.", "" );
if ( !IsObject(wmi) ) then
MessageBox("Failed to connect to WMI.", WARNING);
return false;
endif;
set slist = wmi.ExecQuery("SELECT state FROM Win32_Service WHERE name = 'W3SVC'");
if ( !IsObject(slist) ) then
MessageBox("Failed to get query W3SVC service state.", WARNING);
return false;
endif;
for i = 0 to slist.Count-1
set obj = slist.Item(i);
IISrunning = (obj.state = "Running");
endfor;
catch
MessageBox(Err.Description, WARNING);
return false;
endcatch;
return IISrunning;
end;
Code borrowed from here and here, because I know zero about the IS scripting language. ;-)