Need vbscript that can pop up alert when services go down on a remote computer

30 pts.
Tags:
Scripting
VBScript
Windows scripting
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.
ASKED: April 18, 2008  12:24 PM
UPDATED: April 22, 2008  3:44 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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 & “\root\cimv2″)
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

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Jerry Lees
    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,335 pointsBadges:
    report
  • Naaz
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following