|
Re: checking if remote computer is running
"geos" wrote:
> Gerry Hickman wrote:
> > Hi,
> >
> >> I'd like to check if a remote computer on local network is running. I
> >> found some vbscript/javascript examples that used WMI to look for the
> >> presence of a particular process on the remote machine. these scripts
> >> were run locally via WSH. I adapted this solution to look for the
> >> presence of a process named "System" on the remote computer, and it
> >> worked...
> >
> > That seems like a lot of overhead to me, and anyway you may get lag if
> > the computer is turned off. Why don't you just send a single ping packet
> > and see if you get a reply?
> >
> >> My second question is related to the above: is it possible to change
> >> the "presentation layer" from WSH-popup window to, for example, html
> >> page that would display a table with the names of remote machines
> >> along with their status (running/not running), and refreshing itself
> >> automatically?
> >
> > Yes, first of all you should change your default script host to CSCRIPT,
> > this will make everything happen on the command line, allow command
> > redirection, enable silent running (out of hours), and cut out about a
> > million other problems.
> >
> > Second, if you want a web UI you should use either an HTA (running on
> > the local box), or a web server based solution running on a web server.
>
> hello Gerry,
>
> thanks for your suggestions. in the meantime I found out how to ping
> remote computer with the help of WMI. this solution works for XP and later.
>
> thanks,
> geos
>
> // IsAlive(xHostID) returns the true/false
> // based on ping status code
>
> var IsAlive = function(sHostID) {
> var oLoc = new ActiveXObject('WbemScripting.SWbemLocator');
> var oSrv = oLoc.ConnectServer(null,'/root/cimv2');
> var ePng = new Enumerator(oSrv.ExecQuery(' \
> SELECT * FROM Win32_PingStatus \
> WHERE Address = ' + '"' + sHostID + '"'));
>
> ePng.moveFirst();
> return (ePng.item().StatusCode==0) ? true : false ;
> };
>
> WScript.Echo(''+IsAlive('www.google.com'));
> WScript.Echo(''+IsAlive('localhost'));
>
>
|