30 pts.
 Need vbscript that can pop up alert when services go down on a remote computer
Hi, I have tried many scripts at my local machine. It gave pop up when service for one particular application went down. But the same thing is not happening for the remote computer. Please look at the script below: strComputer = "." Set objFirewall = CreateObject("HNetCfg.FwMgr") Set objPolicy = objFirewall.LocalPolicy.CurrentProfile objPolicy.FirewallEnabled = FALSE Set objAdminSettings = objPolicy.RemoteAdminSettings objAdminSettings.Enabled = TRUE Set oWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!" & sComputerName& "rootcimv2") Set colRunningServices = oWMIService.ExecQuery _ ("SELECT * FROM Win32_Service) For Each oService in colRunningServices Wscript.Echo oService.DisplayName & VbTab & oService.State Next I have tried without the firewal and admin rights settings as well in the above code and giving the IP address of the remote computer in strcomputer="IP Address" It doesn't work. Could you please help me out in knowing the problem with the above or give me some code which can do the purpose. Awaiting eagerly for your response. Many Thanks. Naaz.

Software/Hardware used:
ASKED: April 18, 2008  12:24 PM
UPDATED: April 22, 2008  3:44 PM

Answer Wiki:
Naaz, There were a couple things wrong. You didn't have Select * from Win32_Service terminated with a quote and there were several variations of variables dor the "computer name" (strComputer, sComputerName, etc). I also don't know that you need to use HNetCfg.FwMgr nessisarily, I've disabled it in the code by remarking the two lines that change the settings-- you can unremark them if you need to-- but it seems to work with out it on my system I've fixed the code and it is below: Option explicit Dim sComputer, objFirewall, ObjPolicy, objAdminSettings Dim oService, oWMIService, colRunningServices sComputer = "." Set objFirewall = CreateObject("HNetCfg.FwMgr") Set objPolicy = objFirewall.LocalPolicy.CurrentProfile 'objPolicy.FirewallEnabled = FALSE Set objAdminSettings = objPolicy.RemoteAdminSettings 'objAdminSettings.Enabled = TRUE Set oWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!" & sComputer & "rootcimv2") Set colRunningServices = oWMIService.ExecQuery _ ("SELECT * FROM Win32_Service") For Each oService in colRunningServices Wscript.Echo oService.DisplayName & VbTab & oService.State Next This doesn't help. Please see the discussion below
Last Wiki Answer Submitted:  April 22, 2008  3:44 pm  by  Jerry Lees   5,320 pts.
All Answer Wiki Contributors:  Jerry Lees   5,320 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Be sure and check out my blog here on ITKE for more Network administration and VBSCRIPT tips.
The VBScript Network and Systems Administrator’s Cafe

 5,320 pts.

 

Hi Jlees,

Thanks for your help on this.

But i get error message as “There are no more endpoints available from the endpoint mapper.”

Also, it would be great of you if you can give modified code that can tell me the status of service on a remote computer but not on a local computer.

Thanks much in advance. But m very much in need of your answer on this. Please reply to this asap.

Regs,
Naaz.

 30 pts.