Does anyone have a script that will beep or somthing when a service stops
(or when any services that are automatic stops)? I would think that this is
a simple thing. I don't need a lot of extra stuff just want to monitor some
exchange services.

Re: Script or simple proggy by Dave

Dave
Wed Jul 09 12:09:51 CDT 2003

On the service recovery tab first, second or subsequent failure choose "Run
a program"

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]

"Ed" wrote:
> Does anyone have a script that will beep or somthing when a service stops
> (or when any services that are automatic stops)? I would think that this
is
> a simple thing. I don't need a lot of extra stuff just want to monitor
some
> exchange services.
>
>



Re: Script or simple proggy by Ed

Ed
Wed Jul 09 12:15:18 CDT 2003

Thanks, not exactly what I was looking for. But I can script somthing from
their.
"Dave Patrick" <mail@Nospam.DSPatrick.com> wrote in message
news:emdxszjRDHA.2252@TK2MSFTNGP12.phx.gbl...
> On the service recovery tab first, second or subsequent failure choose
"Run
> a program"
>
> --
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft MVP [Windows NT/2000 Operating Systems]
>
> "Ed" wrote:
> > Does anyone have a script that will beep or somthing when a service
stops
> > (or when any services that are automatic stops)? I would think that
this
> is
> > a simple thing. I don't need a lot of extra stuff just want to monitor
> some
> > exchange services.
> >
> >
>
>



Re: Script or simple proggy by Ed

Ed
Wed Jul 09 12:18:25 CDT 2003

My problem is I can't stand up an HTML server, or install perl. There are
plenty of proggys on sourceforge.net that would do what I want, but they
would violate security regs.
"Dave Patrick" <mail@Nospam.DSPatrick.com> wrote in message
news:emdxszjRDHA.2252@TK2MSFTNGP12.phx.gbl...
> On the service recovery tab first, second or subsequent failure choose
"Run
> a program"
>
> --
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft MVP [Windows NT/2000 Operating Systems]
>
> "Ed" wrote:
> > Does anyone have a script that will beep or somthing when a service
stops
> > (or when any services that are automatic stops)? I would think that
this
> is
> > a simple thing. I don't need a lot of extra stuff just want to monitor
> some
> > exchange services.
> >
> >
>
>



Re: Script or simple proggy by Dave

Dave
Wed Jul 09 12:42:27 CDT 2003

Not sure what you're wanting then. From your post it appeared you were right
next to the box and only wanted a ding or something. If so just have it run
a shell script, something like;

%windir%\Media\ding.wav

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]

"Ed" wrote:
> Thanks, not exactly what I was looking for. But I can script somthing
from
> their.



Re: Script or simple proggy by Ed

Ed
Thu Jul 10 04:50:33 CDT 2003

Sorry, that would be great, but my techs are not always in the office. So I
guess ding and popup would work.
"Dave Patrick" <mail@Nospam.DSPatrick.com> wrote in message
news:Oi6s3FkRDHA.560@TK2MSFTNGP10.phx.gbl...
> Not sure what you're wanting then. From your post it appeared you were
right
> next to the box and only wanted a ding or something. If so just have it
run
> a shell script, something like;
>
> %windir%\Media\ding.wav
>
> --
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft MVP [Windows NT/2000 Operating Systems]
>
> "Ed" wrote:
> > Thanks, not exactly what I was looking for. But I can script somthing
> from
> > their.
>
>



Re: Script or simple proggy by Ed

Ed
Thu Jul 10 05:15:03 CDT 2003

I was more looking for somthing that would open a little IE window that
would constantly show the status of all of the exchange services listing UP
or Down. Seems too complicated though.
"Dave Patrick" <mail@Nospam.DSPatrick.com> wrote in message
news:Oi6s3FkRDHA.560@TK2MSFTNGP10.phx.gbl...
> Not sure what you're wanting then. From your post it appeared you were
right
> next to the box and only wanted a ding or something. If so just have it
run
> a shell script, something like;
>
> %windir%\Media\ding.wav
>
> --
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft MVP [Windows NT/2000 Operating Systems]
>
> "Ed" wrote:
> > Thanks, not exactly what I was looking for. But I can script somthing
> from
> > their.
>
>



Re: Script or simple proggy by Dave

Dave
Thu Jul 10 07:50:10 CDT 2003

I'm sure anything is possible. Seems your wishes have escalated though. :)

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]

"Ed" wrote:
> I was more looking for somthing that would open a little IE window that
> would constantly show the status of all of the exchange services listing
UP
> or Down. Seems too complicated though.



Re: Script or simple proggy by Ross

Ross
Thu Jul 10 11:11:54 CDT 2003

"Ed" <glass walker theurge AT juno DOT com> wrote in
news:OFpDB$jRDHA.304@tk2msftngp13.phx.gbl:

> My problem is I can't stand up an HTML server, or install perl. There
> are plenty of proggys on sourceforge.net that would do what I want,
> but they would violate security regs.

Consider the command line program "psservice" found at winternals.com.

If that violates security regs, then you need WMI to monitor services.
General outline for an HTA that monitors services:

<HTML>
<HTA:APPLICATION ID="wmitester"
APPLICATIONNAME="monitor services using WMI">
<HEAD><SCRIPT language=VBSCRIPT>

' approximate time to wait between checks.
' in my testing, it seems like it's always 1 or 2
' seconds more. Tweak if it matters to you.
Const nSecondsBetweenChecks = 10

' uses the short name of the service (W3SVC), not
' the display name ("World Wide Web Service")
' return "NOTFOUND" if service not installed there
' otherwise return the service status
function ServiceStatus(strComputer,strServiceName)
dim objWMIService
dim colServices
dim objService
dim strWMICall
strWMICall="winmgmts:!\\" & strComputer & "\root\cimv2"
set objWMIService = GetObject(strWMICall)
set colServices = objWMIService.ExecQuery( _
"Select * from Win32_Service where Name=" _
& "'" & strServiceName & "'" )
ServiceStatus = "NOTFOUND"
for each objService in colServices
ServiceStatus = objService.State
next
set objService = Nothing
set colServices = Nothing
set objWMIService = Nothing
end function

' refresh the textboxes on the page
sub RefreshLoop()
dim dtStarted
dtStarted = Now()
document.getElementByID("tb_Timestamp").value = dtStarted
document.getElementByID("tb_SERVER1_NETLOGON").value = _
ServiceStatus("SERVER1","NETLOGON")
document.getElementByID("tb_SERVER1_W3SVC").value = _
ServiceStatus("SERVER1","W3SVC")
document.getElementByID("tb_SERVER2_NETLOGON").value = _
ServiceStatus("SERVER2","NETLOGON")
document.getElementByID("tb_SERVER2_W3SVC").value = _
ServiceStatus("SERVER2","W3SVC")
call setTimeout("RefreshLoop()", _
1000*nSecondsBetweenChecks + (Now()-dtStarted))
end sub
</SCRIPT></HEAD>
<BODY onload="RefreshLoop()">
<FORM>
<P>Last checked at <INPUT id="tb_Timestamp"></P>
<TABLE><TR>
<TD SPANCOLUMNS=*>Computer SERVER1</TD>
</TR><TR>
<TD>NETLOGON service</TD><TD><INPUT id="tb_SERVER1_NETLOGON"></TD>
</TR><TR>
<TD>W3SVC service</TD><TD><INPUT id="tb_SERVER1_W3SVC"></TD>
</TR><TR>
<TD SPANCOLUMNS=*>Computer SERVER2</TD>
</TR><TR>
<TD>NETLOGON service</TD><TD><INPUT id="tb_SERVER2_NETLOGON"></TD>
</TR><TR>
<TD>W3SVC service</TD><TD><INPUT id="tb_SERVER2_W3SVC"></TD>
</TR></TABLE></FORM>
</BODY></HTML>








--
Ross Presser -- rpresser AT imtek DOT com
"... VB is essentially the modern equivalent of vulgar Latin in 13th
Centurary Europe. Understand it, and you can travel to places you never
heard of and still understand some people." -- Alex K. Angelopoulos

Re: Script or simple proggy by Ed

Ed
Thu Jul 10 13:21:14 CDT 2003

I checked this on my Win2k box, cool. Walked over to the server room, and
apparently NT4 dosn't have this function?
"Dave Patrick" <mail@Nospam.DSPatrick.com> wrote in message
news:eHf0OHuRDHA.2240@TK2MSFTNGP11.phx.gbl...
> I'm sure anything is possible. Seems your wishes have escalated though.
:)
>
> --
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft MVP [Windows NT/2000 Operating Systems]
>
> "Ed" wrote:
> > I was more looking for somthing that would open a little IE window that
> > would constantly show the status of all of the exchange services listing
> UP
> > or Down. Seems too complicated though.
>
>



Re: Script or simple proggy by Ed

Ed
Thu Jul 10 13:38:45 CDT 2003

That was exactly what I was looking for, thanks. Unfortuantly WMI does not
seem to work. Possibly been disabled by the security stuff they throw onto
the services. I was looking at PSlist, couldn't I use your HTML thingy to
do the same thing as WMI? I wrote a shell script with grep that checked for
the existance of a thread, if it existed a variable was set to one. If the
variable equalled one, I displayed it as up. Else down. I would think that
I could do the same with this. I have zero expierience with vbscript in
html. I couldn't even figure out how to do it in vbscript.
"Ross Presser" <rpresser@NOSPAM.imtek.com.invalid> wrote in message
news:Xns93B47C16BD86Bpt101594@129.250.170.90...
> "Ed" <glass walker theurge AT juno DOT com> wrote in
> news:OFpDB$jRDHA.304@tk2msftngp13.phx.gbl:
>
> > My problem is I can't stand up an HTML server, or install perl. There
> > are plenty of proggys on sourceforge.net that would do what I want,
> > but they would violate security regs.
>
> Consider the command line program "psservice" found at winternals.com.
>
> If that violates security regs, then you need WMI to monitor services.
> General outline for an HTA that monitors services:
>
> <HTML>
> <HTA:APPLICATION ID="wmitester"
> APPLICATIONNAME="monitor services using WMI">
> <HEAD><SCRIPT language=VBSCRIPT>
>
> ' approximate time to wait between checks.
> ' in my testing, it seems like it's always 1 or 2
> ' seconds more. Tweak if it matters to you.
> Const nSecondsBetweenChecks = 10
>
> ' uses the short name of the service (W3SVC), not
> ' the display name ("World Wide Web Service")
> ' return "NOTFOUND" if service not installed there
> ' otherwise return the service status
> function ServiceStatus(strComputer,strServiceName)
> dim objWMIService
> dim colServices
> dim objService
> dim strWMICall
> strWMICall="winmgmts:!\\" & strComputer & "\root\cimv2"
> set objWMIService = GetObject(strWMICall)
> set colServices = objWMIService.ExecQuery( _
> "Select * from Win32_Service where Name=" _
> & "'" & strServiceName & "'" )
> ServiceStatus = "NOTFOUND"
> for each objService in colServices
> ServiceStatus = objService.State
> next
> set objService = Nothing
> set colServices = Nothing
> set objWMIService = Nothing
> end function
>
> ' refresh the textboxes on the page
> sub RefreshLoop()
> dim dtStarted
> dtStarted = Now()
> document.getElementByID("tb_Timestamp").value = dtStarted
> document.getElementByID("tb_SERVER1_NETLOGON").value = _
> ServiceStatus("SERVER1","NETLOGON")
> document.getElementByID("tb_SERVER1_W3SVC").value = _
> ServiceStatus("SERVER1","W3SVC")
> document.getElementByID("tb_SERVER2_NETLOGON").value = _
> ServiceStatus("SERVER2","NETLOGON")
> document.getElementByID("tb_SERVER2_W3SVC").value = _
> ServiceStatus("SERVER2","W3SVC")
> call setTimeout("RefreshLoop()", _
> 1000*nSecondsBetweenChecks + (Now()-dtStarted))
> end sub
> </SCRIPT></HEAD>
> <BODY onload="RefreshLoop()">
> <FORM>
> <P>Last checked at <INPUT id="tb_Timestamp"></P>
> <TABLE><TR>
> <TD SPANCOLUMNS=*>Computer SERVER1</TD>
> </TR><TR>
> <TD>NETLOGON service</TD><TD><INPUT id="tb_SERVER1_NETLOGON"></TD>
> </TR><TR>
> <TD>W3SVC service</TD><TD><INPUT id="tb_SERVER1_W3SVC"></TD>
> </TR><TR>
> <TD SPANCOLUMNS=*>Computer SERVER2</TD>
> </TR><TR>
> <TD>NETLOGON service</TD><TD><INPUT id="tb_SERVER2_NETLOGON"></TD>
> </TR><TR>
> <TD>W3SVC service</TD><TD><INPUT id="tb_SERVER2_W3SVC"></TD>
> </TR></TABLE></FORM>
> </BODY></HTML>
>
>
>
>
>
>
>
>
> --
> Ross Presser -- rpresser AT imtek DOT com
> "... VB is essentially the modern equivalent of vulgar Latin in 13th
> Centurary Europe. Understand it, and you can travel to places you never
> heard of and still understand some people." -- Alex K. Angelopoulos



Re: Script or simple proggy by Ed

Ed
Fri Jul 11 08:09:48 CDT 2003

They can peek in the dore and see the screen.
"petal" <news@nospam-formline.demon.co.uk> wrote in message
news:OQbpZFzRDHA.1304@TK2MSFTNGP11.phx.gbl...
> if the techs aren't in the office that won't help either...
>
> check out a couple of SMS applications to send to mobiles
> e.g. http://www.notepage.net/pagegate.htm (absolutely no experience of
this
> product but seems to fit your requirement)
>
> as far as IE goes, read the service status, parse and format it to HTML
with
> a refresh and fire it up to your web iste
>
> regards
> petal
>
> "Ed" <glass walker theurge AT juno DOT com> wrote in message
> news:%235pY$2sRDHA.1868@TK2MSFTNGP11.phx.gbl...
> > I was more looking for somthing that would open a little IE window that
> > would constantly show the status of all of the exchange services listing
> UP
> > or Down. Seems too complicated though.
> > "Dave Patrick" <mail@Nospam.DSPatrick.com> wrote in message
> > news:Oi6s3FkRDHA.560@TK2MSFTNGP10.phx.gbl...
> > > Not sure what you're wanting then. From your post it appeared you were
> > right
> > > next to the box and only wanted a ding or something. If so just have
it
> > run
> > > a shell script, something like;
> > >
> > > %windir%\Media\ding.wav
> > >
> > > --
> > > Regards,
> > >
> > > Dave Patrick ....Please no email replies - reply in newsgroup.
> > > Microsoft MVP [Windows NT/2000 Operating Systems]
> > >
> > > "Ed" wrote:
> > > > Thanks, not exactly what I was looking for. But I can script
somthing
> > > from
> > > > their.
> > >
> > >
> >
> >
>
>



Re: Script or simple proggy by Ed

Ed
Fri Jul 11 08:09:11 CDT 2003

What is HTA? I had forgotten about those (cygwin), I already have them
downloaded. I liked C Shell, but I don't know how to do alot of that stuff
in VBScript. Your sample shows alot.
"Ross Presser" <rpresser@NOSPAM.imtek.com.invalid> wrote in message
news:Xns93B4A20E5B3BFpt101594@129.250.170.95...
> "Ed" <glass walker theurge AT juno DOT com> wrote in news:e5kMeQxRDHA.2056
> @TK2MSFTNGP12.phx.gbl:
>
> > Unfortuantly WMI does not
> > seem to work.
>
> If your servers are running NT4 (implied elsewhere in the thread), then
> WMI is not installed by default. It will have to be installed first. This
> may not be allowed in your security environment.
>
> > I was looking at PSlist, couldn't I use your HTML thingy to
> > do the same thing as WMI?
>
> I was referring to psservice rather than pslist, but either should work.
> Below is a version of ServiceStatus() in vbscript that shells to
> PSSERVICE. This will be expensive if you have a lot of services to
> monitor! It has to start a process for each one...
>
> By the way, what I wrote has to be saved as XXXX.HTA, not XXX.HTML - it
> has to run under the HTA environment, not a normal web browser.
>
> > I wrote a shell script with grep that checked for
> > the existance of a thread, if it existed a variable was set to one.
> > If the variable equalled one, I displayed it as up. Else down. I
> > would think that I could do the same with this.
>
> why not use bash/grep here, too? Get bash and grep for Win32 from the
> Cygwin project <http://www.cygwin.com>, use psservice or pslist, and go to
> town. This sounds like it will be easiest for you with your current
> experience.
>
> But here goes, ServiceStatus() using psservice:
>
> function ServiceStatus(strComputer, strService)
> strOutput=Exec_Cmd( _
> "PSSERVICE query \\" & strComputer & " " & strService)
> if instr(strOutput,"STATE")=0 then
> ServiceStatus = "NOTFOUND"
> elseif instr(strOutput,"STATE : 4 RUNNING")>0 then
> ServiceStatus = "Running"
> else
> ServiceStatus = "Stopped"
> end if
> end function
>
> Function Exec_Cmd(cmdline)
> ' thanks to Alex K. Angeloupoulos
> Set objShell = CreateObject("WScript.Shell")
> Set objExCmd = objShell.Exec("%COMSPEC% /C " & cmdline)
> Set objExCmdStdOut = objExCmd.StdOut
> Set objExCmdStdErr = objExCmd.StdErr
> Do: WScript.Sleep 10
> Do Until objExCmdStdOut.AtEndOfStream
> Exec_Cmd = Exec_Cmd & objExCmdStdOut.ReadAll
> CmdErr = CmdErr & objExCmdStdErr.ReadAll
> Loop
> Loop Until objExCmd.Status <> 0
> and objExCmdStdOut.AtEndOfStream
> End Function
>
> --
> Ross Presser -- rpresser AT imtek DOT com
> "... VB is essentially the modern equivalent of vulgar Latin in 13th
> Centurary Europe. Understand it, and you can travel to places you never
> heard of and still understand some people." -- Alex K. Angelopoulos



Re: Script or simple proggy by Ross

Ross
Fri Jul 11 14:36:40 CDT 2003

"Ed" <glass walker theurge AT juno DOT com> wrote in news:eSK##86RDHA.2480
@tk2msftngp13.phx.gbl:

> What is HTA?

An HTML Application. It runs in a far looser security context than HTML in
a web browser, and has additional parameters to control its look. The
Scriptomatic and Alex's Stringomatic are two excellent examples of HTA.

<http://www.microsoft.com/technet/treeview/default.asp?
url=/technet/scriptcenter/scrguide/sas_ent_hipz.asp>



--
Ross Presser -- rpresser AT imtek DOT com
"... VB is essentially the modern equivalent of vulgar Latin in 13th
Centurary Europe. Understand it, and you can travel to places you never
heard of and still understand some people." -- Alex K. Angelopoulos

Re: Script or simple proggy by Ross

Ross
Mon Jul 14 14:31:29 CDT 2003

"Ed" <glass walker theurge AT juno DOT com> wrote in
news:u0rNBnjSDHA.2128@TK2MSFTNGP12.phx.gbl:

> Here is a rough of what I am trying to do. I had to comment the line
> that says "' and objExCmdStdOut.AtEndOfStream" otherwise I get an
> error I can't trace. I am not getting a proper reading. When I
> command line it, I get a proper result but the script is not pulling
> back the result.

IE places security restrictions on what scripts inside HTML pages can run.
HTA was designed for this. It runs on the client, and it looks like HTML,
but the security restrictions are relaxed.

--
Ross Presser -- rpresser AT imtek DOT com
"... VB is essentially the modern equivalent of vulgar Latin in 13th
Centurary Europe. Understand it, and you can travel to places you never
heard of and still understand some people." -- Alex K. Angelopoulos

Re: Script or simple proggy by Ed

Ed
Tue Jul 15 04:34:48 CDT 2003

Will the below script work in HTA, what are the differances? Do I need a
server, or can I just run the .hta? Thanks in advance for your help. I am
googling as I write this.
"Ross Presser" <rpresser@NOSPAM.imtek.com.invalid> wrote in message
news:Xns93B89DEDDD350pt101594@129.250.170.93...
> "Ed" <glass walker theurge AT juno DOT com> wrote in
> news:u0rNBnjSDHA.2128@TK2MSFTNGP12.phx.gbl:
>
> > Here is a rough of what I am trying to do. I had to comment the line
> > that says "' and objExCmdStdOut.AtEndOfStream" otherwise I get an
> > error I can't trace. I am not getting a proper reading. When I
> > command line it, I get a proper result but the script is not pulling
> > back the result.
>
> IE places security restrictions on what scripts inside HTML pages can run.
> HTA was designed for this. It runs on the client, and it looks like HTML,
> but the security restrictions are relaxed.
>
> --
> Ross Presser -- rpresser AT imtek DOT com
> "... VB is essentially the modern equivalent of vulgar Latin in 13th
> Centurary Europe. Understand it, and you can travel to places you never
> heard of and still understand some people." -- Alex K. Angelopoulos



Re: Script or simple proggy by Ed

Ed
Tue Jul 15 04:51:29 CDT 2003

Since this script builds the HTML "on the go", it should work? I am not
sure, I was going to have it loop through all the services that I was
looking for until a key is pressed. I have yet to find a solid referance on
the differance between HTA and HTML.
"Ed" <glass walker theurge AT juno DOT com> wrote in message
news:u0rNBnjSDHA.2128@TK2MSFTNGP12.phx.gbl...
> Here is a rough of what I am trying to do. I had to comment the line that
> says "' and objExCmdStdOut.AtEndOfStream" otherwise I get an error I
can't
> trace. I am not getting a proper reading. When I command line it, I get
a
> proper result but the script is not pulling back the result.
>
> ' Author: Tony Hinkle
> ' tonyhinkle@yahoo.com
>
> ' The only original part I came up with is make the DIV element an
> ' object and change its innerHTML property. I'm sure someone else
> ' has done it, but I couldn't find an example anywhere.
>
> ' This capability makes IE an excellent output device for WSH.
> ' Output can be sent to IE, and it is not necessary to refresh or reload.
>
> ' I know it's sloppy--it's a sample that runs for 10 seconds...
>
> Set WSHShell = WScript.CreateObject("WScript.Shell")
> Set IE = CreateObject("InternetExplorer.Application")
> Set fso = CreateObject("Scripting.FileSystemObject")
>
> 'Create a path and filename to a file in My Documents
> strMyDocPath = WshShell.SpecialFolders("MyDocuments")
> strTempFile = strMyDocPath & "\DIVExample.html"
>
> 'Create a file
> fso.CreateTextFile (strTempFile)
> Set f1 = fso.GetFile(strTempFile)
> Set ts = f1.OpenAsTextStream(2, True)
>
> 'Write a blank HTML page to the file with an empty DIV element, and then
> close the file
> ts.WriteLine("<HTML><HEAD><TITLE>Changing DIV's innerHTML from
> VBScript</TITLE></HEAD>")
> ts.WriteLine("<BODY SCROLL='NO'><CENTER><FONT FACE='arial black'> <HR
> COLOR='BLACK'>")
> ts.WriteLine("<DIV id='MakeMeAnObject'></DIV>")
> ts.WriteLine("<HR COLOR='BLACK'></FONT></CENTER></BODY></HTML>")
> ts.Close
>
> 'Run IE and load the file we just created
> SetupIE(strTempFile)
>
> 'Set the DIV element as an object
> Set objDIV = IE.Document.All("MakeMeAnObject")
>
> 'Change the innerHTML of the DIV object
> ServiceStatus "\\VRC40ADP2", "PolicyAgent", STPolicyAgent
> objDiv.InnerHTML = "Policy Agent is : " & STPolicyAgent
> WScript.Sleep 4000
>
> 'Close IE and delete the file
> IE.Quit
> f1.Delete
>
> Sub SetupIE(File2Load)
> IE.Navigate File2Load
> IE.ToolBar = False
> IE.StatusBar = False
> IE.Resizable = False
>
> Do
> Loop While IE.Busy
>
> IE.Width = 500
> IE.Height = 110
> IE.Left = 0
> IE.Top = 0
> IE.Visible = True
> WshShell.AppActivate("Microsoft Internet Explorer")
> End Sub
>
> function ServiceStatus(strComputer, strService, Result)
> strOutput=Exec_Cmd( _
> "PSSERVICE \\" & strComputer & " query " & strService)
> if instr(strOutput,"STATE")=0 then
> Result = "NOTFOUND"
> elseif instr(strOutput,"STATE : 4 RUNNING")>0 then
> Result = "Running"
> else
> Result = "Stopped"
> end if
> end function
>
> Function Exec_Cmd(cmdline)
> ' thanks to Alex K. Angeloupoulos
> Set objShell = CreateObject("WScript.Shell")
> Set objExCmd = objShell.Exec("%COMSPEC% /C " & cmdline)
> Set objExCmdStdOut = objExCmd.StdOut
> Set objExCmdStdErr = objExCmd.StdErr
> Do: WScript.Sleep 10
> Do Until objExCmdStdOut.AtEndOfStream
> Exec_Cmd = Exec_Cmd & objExCmdStdOut.ReadAll
> CmdErr = CmdErr & objExCmdStdErr.ReadAll
> Loop
> Loop Until objExCmd.Status <> 0
> ' and objExCmdStdOut.AtEndOfStream
> end function
>
> "Ross Presser" <rpresser@NOSPAM.imtek.com.invalid> wrote in message
> news:Xns93B4A20E5B3BFpt101594@129.250.170.95...
> > "Ed" <glass walker theurge AT juno DOT com> wrote in
news:e5kMeQxRDHA.2056
> > @TK2MSFTNGP12.phx.gbl:
> >
> > > Unfortuantly WMI does not
> > > seem to work.
> >
> > If your servers are running NT4 (implied elsewhere in the thread), then
> > WMI is not installed by default. It will have to be installed first.
This
> > may not be allowed in your security environment.
> >
> > > I was looking at PSlist, couldn't I use your HTML thingy to
> > > do the same thing as WMI?
> >
> > I was referring to psservice rather than pslist, but either should work.
> > Below is a version of ServiceStatus() in vbscript that shells to
> > PSSERVICE. This will be expensive if you have a lot of services to
> > monitor! It has to start a process for each one...
> >
> > By the way, what I wrote has to be saved as XXXX.HTA, not XXX.HTML - it
> > has to run under the HTA environment, not a normal web browser.
> >
> > > I wrote a shell script with grep that checked for
> > > the existance of a thread, if it existed a variable was set to one.
> > > If the variable equalled one, I displayed it as up. Else down. I
> > > would think that I could do the same with this.
> >
> > why not use bash/grep here, too? Get bash and grep for Win32 from the
> > Cygwin project <http://www.cygwin.com>, use psservice or pslist, and go
to
> > town. This sounds like it will be easiest for you with your current
> > experience.
> >
> > But here goes, ServiceStatus() using psservice:
> >
> > function ServiceStatus(strComputer, strService)
> > strOutput=Exec_Cmd( _
> > "PSSERVICE query \\" & strComputer & " " & strService)
> > if instr(strOutput,"STATE")=0 then
> > ServiceStatus = "NOTFOUND"
> > elseif instr(strOutput,"STATE : 4 RUNNING")>0 then
> > ServiceStatus = "Running"
> > else
> > ServiceStatus = "Stopped"
> > end if
> > end function
> >
> > Function Exec_Cmd(cmdline)
> > ' thanks to Alex K. Angeloupoulos
> > Set objShell = CreateObject("WScript.Shell")
> > Set objExCmd = objShell.Exec("%COMSPEC% /C " & cmdline)
> > Set objExCmdStdOut = objExCmd.StdOut
> > Set objExCmdStdErr = objExCmd.StdErr
> > Do: WScript.Sleep 10
> > Do Until objExCmdStdOut.AtEndOfStream
> > Exec_Cmd = Exec_Cmd & objExCmdStdOut.ReadAll
> > CmdErr = CmdErr & objExCmdStdErr.ReadAll
> > Loop
> > Loop Until objExCmd.Status <> 0
> > and objExCmdStdOut.AtEndOfStream
> > End Function
> >
> > --
> > Ross Presser -- rpresser AT imtek DOT com
> > "... VB is essentially the modern equivalent of vulgar Latin in 13th
> > Centurary Europe. Understand it, and you can travel to places you never
> > heard of and still understand some people." -- Alex K. Angelopoulos
>
>



Re: Script or simple proggy by Ed

Ed
Tue Jul 15 13:10:25 CDT 2003

The below script generates an html page that is displayed in IE. But it
only writes the page. The actual workhorse is VB, so it is not restricted
by HTML limitations. And since I can not stand up a web server to do this
this is perfect (accept that I don't understand how it works so well). I
have come up with somthing that partially works. It just gives wrong info.
It says "not found", due to some coding error, that I cant find. It may be
logic based.

' Author: Tony Hinkle
' tonyhinkle@yahoo.com

' The only original part I came up with is make the DIV element an
' object and change its innerHTML property. I'm sure someone else
' has done it, but I couldn't find an example anywhere.

' This capability makes IE an excellent output device for WSH.
' Output can be sent to IE, and it is not necessary to refresh or reload.

' I know it's sloppy--it's a sample that runs for 10 seconds...

Set WSHShell = WScript.CreateObject("WScript.Shell")
Set IE = CreateObject("InternetExplorer.Application")
Set fso = CreateObject("Scripting.FileSystemObject")

'Create a path and filename to a file in My Documents
strMyDocPath = WshShell.SpecialFolders("MyDocuments")
strTempFile = strMyDocPath & "\DIVExample.html"

'Create a file
fso.CreateTextFile (strTempFile)
Set f1 = fso.GetFile(strTempFile)
Set ts = f1.OpenAsTextStream(2, True)

'Write a blank HTML page to the file with an empty DIV element, and then
close the file
ts.WriteLine("<HTML><HEAD><TITLE>Changing DIV's innerHTML from
VBScript</TITLE></HEAD>")
ts.WriteLine("<BODY SCROLL='NO'><CENTER><FONT FACE='arial black'> <HR
COLOR='BLACK'>")
ts.WriteLine("<DIV id='MakeMeAnObject'></DIV>")
ts.WriteLine("<HR COLOR='BLACK'></FONT></CENTER></BODY></HTML>")
ts.Close

'Run IE and load the file we just created
SetupIE(strTempFile)

'Set the DIV element as an object
Set objDIV = IE.Document.All("MakeMeAnObject")

'Change the innerHTML of the DIV object
ServiceStatus "\\VRC40ADP2", "PolicyAgent", STPolicyAgent
objDiv.InnerHTML = "Policy Agent is : " & STPolicyAgent
WScript.Sleep 4000

'Close IE and delete the file
IE.Quit
f1.Delete

Sub SetupIE(File2Load)
IE.Navigate File2Load
IE.ToolBar = False
IE.StatusBar = False
IE.Resizable = False

Do
Loop While IE.Busy

IE.Width = 500
IE.Height = 110
IE.Left = 0
IE.Top = 0
IE.Visible = True
WshShell.AppActivate("Microsoft Internet Explorer")
End Sub

function ServiceStatus(strComputer, strService, Result)
strOutput=Exec_Cmd( _
"PSSERVICE \\" & strComputer & " query " & strService)
if instr(strOutput,"STATE")=0 then
Result = "NOTFOUND"
elseif instr(strOutput,"STATE : 4 RUNNING")>0 then
Result = "Running"
else
Result = "Stopped"
end if
end function

Function Exec_Cmd(cmdline)
' thanks to Alex K. Angeloupoulos
Set objShell = CreateObject("WScript.Shell")
Set objExCmd = objShell.Exec("%COMSPEC% /C " & cmdline)
Set objExCmdStdOut = objExCmd.StdOut
Set objExCmdStdErr = objExCmd.StdErr
Do: WScript.Sleep 10
Do Until objExCmdStdOut.AtEndOfStream
Exec_Cmd = Exec_Cmd & objExCmdStdOut.ReadAll
CmdErr = CmdErr & objExCmdStdErr.ReadAll
Loop
Loop Until objExCmd.Status <> 0
' and objExCmdStdOut.AtEndOfStream
end function

"Ross Presser" <rpresser@NOSPAM.imtek.com.invalid> wrote in message
news:Xns93B980A22EF73pt101594@129.250.170.91...
> "Ed" <glass walker theurge AT juno DOT com> wrote in
> news:OgVB2XrSDHA.1552@TK2MSFTNGP12.phx.gbl:
>
> > Will the below script work in HTA, what are the differances? Do I
> > need a server, or can I just run the .hta? Thanks in advance for your
> > help. I am googling as I write this.
>
> Well, the script is no longer "below" ... but the point is this:
basically,
> any HTML page whatsoever, saved as a local file, will run as an HTA. It
> gets the benefit of looser security restrictions. Think of HTA.EXE as
> another browser, like IE or Netscape, but one that is very unsafe. :)
>
> --
> Ross Presser -- rpresser AT imtek DOT com
> "... VB is essentially the modern equivalent of vulgar Latin in 13th
> Centurary Europe. Understand it, and you can travel to places you never
> heard of and still understand some people." -- Alex K. Angelopoulos



Re: Script or simple proggy by Ed

Ed
Tue Jul 15 13:21:37 CDT 2003

I fixed it, it now works on my win2k box. Syntax error. :-(

' Author: Tony Hinkle
' tonyhinkle@yahoo.com

' The only original part I came up with is make the DIV element an
' object and change its innerHTML property. I'm sure someone else
' has done it, but I couldn't find an example anywhere.

' This capability makes IE an excellent output device for WSH.
' Output can be sent to IE, and it is not necessary to refresh or reload.

' I know it's sloppy--it's a sample that runs for 10 seconds...

Set WSHShell = WScript.CreateObject("WScript.Shell")
Set IE = CreateObject("InternetExplorer.Application")
Set fso = CreateObject("Scripting.FileSystemObject")

'Create a path and filename to a file in My Documents
strMyDocPath = WshShell.SpecialFolders("MyDocuments")
strTempFile = strMyDocPath & "\DIVExample.html"

'Create a file
fso.CreateTextFile (strTempFile)
Set f1 = fso.GetFile(strTempFile)
Set ts = f1.OpenAsTextStream(2, True)

'Write a blank HTML page to the file with an empty DIV element, and then
close the file
ts.WriteLine("<HTML><HEAD><TITLE>Changing DIV's innerHTML from
VBScript</TITLE></HEAD>")
ts.WriteLine("<BODY SCROLL='NO'><CENTER><FONT FACE='arial black'> <HR
COLOR='BLACK'>")
ts.WriteLine("<DIV id='MakeMeAnObject'></DIV>")
ts.WriteLine("<HR COLOR='BLACK'></FONT></CENTER></BODY></HTML>")
ts.Close

'Run IE and load the file we just created
SetupIE(strTempFile)

'Set the DIV element as an object
Set objDIV = IE.Document.All("MakeMeAnObject")

'Change the innerHTML of the DIV object
ServiceStatus "\\VRC40ADP2", "PolicyAgent", STPolicyAgent
objDiv.InnerHTML = "Policy Agent is : " & STPolicyAgent
WScript.Sleep 4000

'Close IE and delete the file
IE.Quit
f1.Delete

Sub SetupIE(File2Load)
IE.Navigate File2Load
IE.ToolBar = False
IE.StatusBar = False
IE.Resizable = False

Do
Loop While IE.Busy

IE.Width = 500
IE.Height = 110
IE.Left = 0
IE.Top = 0
IE.Visible = True
WshShell.AppActivate("Microsoft Internet Explorer")
End Sub

function ServiceStatus(strComputer, strService, Result)
strOutput = Exec_Cmd("PSSERVICE " & strComputer & " query " & strService)
wscript.echo strOutput
if instr(strOutput,"STATE") = 0 then
Result = "NOTFOUND"
' elseif instr(strOutput,"STATE : 4 RUNNING")>0 then
elseif instr(strOutput,"4 RUNNING") <> 0 then
Result = "Running"
else
Result = "Stopped"
end if
end function

Function Exec_Cmd(cmdline)
' thanks to Alex K. Angeloupoulos
Set objShell = CreateObject("WScript.Shell")
Set objExCmd = objShell.Exec("%COMSPEC% /C " & cmdline)
Set objExCmdStdOut = objExCmd.StdOut
Set objExCmdStdErr = objExCmd.StdErr
Do: WScript.Sleep 10
Do Until objExCmdStdOut.AtEndOfStream
Exec_Cmd = Exec_Cmd & objExCmdStdOut.ReadAll
CmdErr = CmdErr & objExCmdStdErr.ReadAll
Loop
Loop Until objExCmd.Status <> 0
' and objExCmdStdOut.AtEndOfStream
end function

"Ed" <glass walker theurge AT juno DOT com> wrote in message
news:%23vYS$3vSDHA.2280@TK2MSFTNGP12.phx.gbl...
> The below script generates an html page that is displayed in IE. But it
> only writes the page. The actual workhorse is VB, so it is not restricted
> by HTML limitations. And since I can not stand up a web server to do this
> this is perfect (accept that I don't understand how it works so well). I
> have come up with somthing that partially works. It just gives wrong
info.
> It says "not found", due to some coding error, that I cant find. It may
be
> logic based.
>
> ' Author: Tony Hinkle
> ' tonyhinkle@yahoo.com
>
> ' The only original part I came up with is make the DIV element an
> ' object and change its innerHTML property. I'm sure someone else
> ' has done it, but I couldn't find an example anywhere.
>
> ' This capability makes IE an excellent output device for WSH.
> ' Output can be sent to IE, and it is not necessary to refresh or reload.
>
> ' I know it's sloppy--it's a sample that runs for 10 seconds...
>
> Set WSHShell = WScript.CreateObject("WScript.Shell")
> Set IE = CreateObject("InternetExplorer.Application")
> Set fso = CreateObject("Scripting.FileSystemObject")
>
> 'Create a path and filename to a file in My Documents
> strMyDocPath = WshShell.SpecialFolders("MyDocuments")
> strTempFile = strMyDocPath & "\DIVExample.html"
>
> 'Create a file
> fso.CreateTextFile (strTempFile)
> Set f1 = fso.GetFile(strTempFile)
> Set ts = f1.OpenAsTextStream(2, True)
>
> 'Write a blank HTML page to the file with an empty DIV element, and then
> close the file
> ts.WriteLine("<HTML><HEAD><TITLE>Changing DIV's innerHTML from
> VBScript</TITLE></HEAD>")
> ts.WriteLine("<BODY SCROLL='NO'><CENTER><FONT FACE='arial black'> <HR
> COLOR='BLACK'>")
> ts.WriteLine("<DIV id='MakeMeAnObject'></DIV>")
> ts.WriteLine("<HR COLOR='BLACK'></FONT></CENTER></BODY></HTML>")
> ts.Close
>
> 'Run IE and load the file we just created
> SetupIE(strTempFile)
>
> 'Set the DIV element as an object
> Set objDIV = IE.Document.All("MakeMeAnObject")
>
> 'Change the innerHTML of the DIV object
> ServiceStatus "\\VRC40ADP2", "PolicyAgent", STPolicyAgent
> objDiv.InnerHTML = "Policy Agent is : " & STPolicyAgent
> WScript.Sleep 4000
>
> 'Close IE and delete the file
> IE.Quit
> f1.Delete
>
> Sub SetupIE(File2Load)
> IE.Navigate File2Load
> IE.ToolBar = False
> IE.StatusBar = False
> IE.Resizable = False
>
> Do
> Loop While IE.Busy
>
> IE.Width = 500
> IE.Height = 110
> IE.Left = 0
> IE.Top = 0
> IE.Visible = True
> WshShell.AppActivate("Microsoft Internet Explorer")
> End Sub
>
> function ServiceStatus(strComputer, strService, Result)
> strOutput=Exec_Cmd( _
> "PSSERVICE \\" & strComputer & " query " & strService)
> if instr(strOutput,"STATE")=0 then
> Result = "NOTFOUND"
> elseif instr(strOutput,"STATE : 4 RUNNING")>0 then
> Result = "Running"
> else
> Result = "Stopped"
> end if
> end function
>
> Function Exec_Cmd(cmdline)
> ' thanks to Alex K. Angeloupoulos
> Set objShell = CreateObject("WScript.Shell")
> Set objExCmd = objShell.Exec("%COMSPEC% /C " & cmdline)
> Set objExCmdStdOut = objExCmd.StdOut
> Set objExCmdStdErr = objExCmd.StdErr
> Do: WScript.Sleep 10
> Do Until objExCmdStdOut.AtEndOfStream
> Exec_Cmd = Exec_Cmd & objExCmdStdOut.ReadAll
> CmdErr = CmdErr & objExCmdStdErr.ReadAll
> Loop
> Loop Until objExCmd.Status <> 0
> ' and objExCmdStdOut.AtEndOfStream
> end function
>
> "Ross Presser" <rpresser@NOSPAM.imtek.com.invalid> wrote in message
> news:Xns93B980A22EF73pt101594@129.250.170.91...
> > "Ed" <glass walker theurge AT juno DOT com> wrote in
> > news:OgVB2XrSDHA.1552@TK2MSFTNGP12.phx.gbl:
> >
> > > Will the below script work in HTA, what are the differances? Do I
> > > need a server, or can I just run the .hta? Thanks in advance for your
> > > help. I am googling as I write this.
> >
> > Well, the script is no longer "below" ... but the point is this:
> basically,
> > any HTML page whatsoever, saved as a local file, will run as an HTA. It
> > gets the benefit of looser security restrictions. Think of HTA.EXE as
> > another browser, like IE or Netscape, but one that is very unsafe. :)
> >
> > --
> > Ross Presser -- rpresser AT imtek DOT com
> > "... VB is essentially the modern equivalent of vulgar Latin in 13th
> > Centurary Europe. Understand it, and you can travel to places you never
> > heard of and still understand some people." -- Alex K. Angelopoulos
>
>