checking if remote computer is running

G

geos

hello,

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...

I am a beginner to WMI and I realize this is neither very elegant nor
universal solution. My question is: is there a way to do it better? If
so, I would greatly appreciate any examples, comments etc.

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?

thanks,
geos

ps. If this is not the right group to ask this sort of questions I would
appreciate redirections to the more appropriate ones.
 
G

Gerry Hickman

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.
 
G

geos

Gerry said:
Hi,


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?


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'));
 
G

guzarva

geos said:
hello,

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...

I am a beginner to WMI and I realize this is neither very elegant nor
universal solution. My question is: is there a way to do it better? If
so, I would greatly appreciate any examples, comments etc.

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?

thanks,
geos

ps. If this is not the right group to ask this sort of questions I would
appreciate redirections to the more appropriate ones.
 
G

guzarva

Gerry Hickman said:
Hi,


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?


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.
 
G

guzarva

geos said:
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'));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top