;
; SERVICE.KIX
;
; REQUIRES: WINDOWS 2000 & INTERNET EXPLORER
;
; AUTHOR: Shawn and the "Gang" at http://www.kixtart.org
;
break on
$computer = "@wksta"
$program = "SERVICE"
$title = "SERVICE BROWSER"
$top = "100"
$left = "200"
$height = "450"
$width = "500"
$sleep = 1
$crlf = chr(13)+chr(10)
$false = 0
$true = -1
;====
:init
;====
gosub HTML
gosub formLoad
gosub computerChange
gosub serviceChange
gosub eventDispatch
gosub formUnload
exit
;=============
:eventDispatch
;=============
$= oleputproperty( $ie, "visible", "s", "$true")
while olegetproperty ( $ie, "visible" ) = 0 and @error = 0 loop
$= setfocus ( "$program" )
while @error = 0
sleep $sleep
; Get form event ...
$event = olegetproperty ( $frmEvent, "value" )
if $event <> "0"
select
case $event = "1" ; SERVICE CHANGE
gosub serviceChange
case $event = "2" ; REFRESH
gosub serviceChange
case $event = "3" ; START
gosub startClick
gosub serviceChange
case $event = "4" ; STOP
gosub stopClick
gosub serviceChange
case $event = "5" ; PAUSE
gosub pauseClick
gosub serviceChange
case $event = "6" ; RESUME
gosub resumeClick
gosub serviceChange
case $event = "7" ; COMPUTER
gosub computerChange
gosub serviceChange
case $event = "-1" ; CLOSE
return
endselect
$= oleputproperty ( $frmEvent, "value", "s", "0" )
endif
loop
return
;=============
:serviceChange
;=============
; Set service properties to blank for warm and fuzzy
$= oleputproperty ( $frmDescription, "value", "s", "" )
$= oleputproperty ( $frmState, "value", "s", "" )
$= oleputproperty ( $frmStatus, "value", "s", "" )
$= oleputproperty ( $frmProcId, "value", "s", "" )
$= oleputproperty ( $frmServType, "value", "s", "" )
gosub serviceQuery
if $service
$description = olegetproperty($service,"displayName")
$state = olegetproperty($service,"state")
$status = olegetproperty($service,"status")
$processId = olegetproperty($service,"processId")
$serviceType = olegetproperty($service,"serviceType")
$= oleputproperty ( $frmDescription, "value", "s", "$description" )
$= oleputproperty ( $frmState, "value", "s", "$state" )
$= oleputproperty ( $frmStatus, "value", "s", "$status" )
$= oleputproperty ( $frmProcId, "value", "s", "$processId" )
$= oleputproperty ( $frmServType, "value", "s", "$serviceType" )
$= olereleaseobject ( $service )
endif
return
;=========
:stopClick
;=========
gosub serviceQuery
if $service
$= olecallfunc ( $service, "stopService" )
$= olereleaseobject ( $service )
endif
return
;==========
:startClick
;==========
gosub serviceQuery
if $service
$= olecallfunc ( $service, "startService" )
$= olereleaseobject ( $service )
endif
return
;==========
:pauseClick
;==========
gosub serviceQuery
if $service
$= olecallfunc ( $service, "pauseService" )
$= olereleaseobject ( $service )
endif
return
;===========
:resumeClick
;===========
gosub serviceQuery
if $service
$= olecallfunc ( $service, "resumeService" )
$= olereleaseobject ( $service )
endif
return
;==============
:computerChange
;==============
$oldComputer = $computer
$oldWmi = $wmi
$computer = ucase(olegetproperty ( $frmComputer, "value" ))
if $computer
$= oleputproperty ( $frmComputer, "value", "s", "$computer" )
else
$computer = "@wksta"
$= oleputproperty ( $frmComputer, "value", "s", "$computer" )
endif
$wmi = olegetobject ( 0, "winmgmts:{impersonationLevel=impersonate}!//$computer" )
if @error
$computer = $oldComputer
$= oleputproperty ( $frmComputer, "value", "s", "$computer" )
$wmi = $oldWmi
return
endif
$= oleputproperty ( $frmServices, "innerHTML", "s", "<select></select>" )
$select = 'select * from Win32_Service'
$query = val ( "&" + olecallfunc ( $wmi, "execquery", "s", "$select" ))
$enumeration = oleenumobject ( $query )
$service = oleenumobject ( $query, $enumeration )
$dhtml = '<select id=mService onchange="mEvent.value=1" size=1>$crlf'
while @error = 0
$name = olegetproperty ( $service, "name" )
$displayName = olegetproperty ( $service, "displayName" )
$dhtml = $dhtml + '<option id=1 value="$name">$displayName</option>$crlf'
$rs = olereleaseobject ( $service )
$service = oleenumobject ( $query, $enumeration )
loop
$dhtml = $dhtml + '</select>$crlf'
$= oleputproperty ( $frmServices, "innerHTML", "s", "$dhtml" )
if $frmService
$= olereleaseobject ( $frmService )
endif
$frmService = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mService" ))
$= olereleaseobject ( $query )
$= olereleaseobject ( $collection )
return
;========
:formLoad
;========
; Create instance of Internet Explorer ...
$ie = olecreateobject("internetexplorer.application")
; Set properties and display form ...
$nul = oleputproperty ($ie, "addressbar","s","$false")
$nul = oleputproperty ($ie, "menubar", "s", "$false")
$nul = oleputproperty ($ie, "toolbar", "s", "$false")
$nul = oleputproperty ($ie, "statusbar", "s", "$false")
$nul = oleputproperty ($ie, "top", "s", "$top")
$nul = oleputproperty ($ie, "left", "s", "$left")
$nul = oleputproperty ($ie, "height", "s", "$height")
$nul = oleputproperty ($ie, "width", "s", "$width")
$nul = olecallfunc ($ie, "navigate", "s", "about:blank")
; Wait for Internet Explorer to naviate ...
while olegetproperty($ie, "busy") <> "0" and @error = 0 loop
; Get a handle to the active document ...
$doc = val("&" + olegetproperty($ie, "document"))
$nul = olecallfunc($doc, "write", "s", "$htmlForm" )
; Get a handle to the form controls ...
$frmEvent = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mEvent" ))
$frmComputer = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mComputer" ))
$frmServices = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mServices" ))
$frmState = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mState" ))
$frmStatus = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mStatus" ))
$frmProcId = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mProcId" ))
$frmServType = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mServType" ))
$frmDescription = val ( "&" + olecallfunc ( $doc, "getElementById", "s", "mDescription" ))
$= oleputproperty ( $frmComputer, "value", "s", "$computer" )
return
;==========
:formUnload
;==========
if ( $ie )
$= olecallfunc ( $ie, "quit" )
$= olereleaseobject ( $ie )
endif
if ( $wmi )
$= olereleaseobject ( $wmi )
endif
return
;============
:serviceQuery
;============
$name = olegetproperty ( $frmService, "value" )
$select = 'select * from Win32_Service where name="$name"'
$query = val ( "&" + olecallfunc ( $wmi, "execquery", "s", "$select" ))
$enumeration = oleenumobject ( $query )
$service = oleenumobject ( $query, $enumeration )
$= olereleaseobject ( $enumeration )
$= olereleaseobject ( $query )
return
;====
:HTML
;====
$htmlForm = '
<html>
<head>
<title>$program</title>
<h4 align=center><strong>$title</strong></h4>
<h6 align=center>
<strong>
KiXtart Version @KIX<br>
Powered by Microsoft Windows 2000 and Internet Explorer
</strong>
</h6>
<style>
<!---body {
background-color: powderblue; color: black;
font-family: arial; font-size: 10pt; margin: 3px
input.tbox { border: lpx black solid; font: 10pt arial}
td { font: 10pt arial; }
}
--->
</style>
</head>
<body scroll=no>
<input type=hidden id=mEvent name=mEvent value=0>
<table align=center>
<tr>
<td>Computer:<td><input id=mComputer type=tbox>
<input type=button value="Connect" onclick="mEvent.value=7"></td>
<tr>
<td>Service:</td>
<td id=mServices>
<select onchange="mEvent.value=1" size=1>
<select></select>
</td>
<br>
<tr><td>State: <td><input id=mState type=tbox disabled></td>
<tr><td>Status: <td><input id=mStatus type=tbox disabled></td>
<tr><td>ProcessId: <td><input id=mProcId type=tbox disabled></td>
<tr><td>ServiceType:<td><input id=mServType type=tbox disabled></td>
</table>
<br>
<table align=center>
<td><input type=button value="Refresh" onclick="mEvent.value=2"></td>
<td><input type=button value=" Start " onclick="mEvent.value=3"></td>
<td><input type=button value=" Stop " onclick="mEvent.value=4"></td>
<td><input type=button value=" Pause " onclick="mEvent.value=5"></td>
<td><input type=button value=" Resume" onclick="mEvent.value=6"></td>
<td><input type=button value=" Close " onclick="mEvent.value=-1"></td>
</table>
<br><hr>
<h6 align=center>
For questions or feedback concerning this utility, please contact
<br>
<a href="http://www.kixtart.org">The KiXtart Bulletin Board</a>
</h6>
</body>
</html>
'
return