[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 828
  • Last Modified:

Need to Execute VBScript After All Cluster Resources Fail

Hello Experts,
I need to execute this script after all the cluster resources on Windows Server 2008 fail. Please help.
Thank you!


Script I need to execute:

Dim objShell : Set objShell = CreateObject("Wscript.Shell")

With objShell
  .Run "schtasks.exe /change /tn " & chr(34) & "\Microsoft\TaskName" & chr(34) & " /enable"
  .Run "schtasks.exe /run /tn " & chr(34) & "\Microsoft\TaskName" & chr(34)
  .Run "schtasks.exe /end /s server.domain.com /tn " & chr(34) & "\Microsoft\TaskName" & chr(34)
  .Run "schtasks.exe /change /s server.domain.com /tn " & chr(34) & "\Microsoft\TaskName" & chr(34) & " /disable"
End With

Is this the correct format with the function variable for cluster?

Function Online( )

On Error Resume Next

Dim objShell : Set objShell = CreateObject("Wscript.Shell")

With objShell
  .Run "schtasks.exe /change /tn " & chr(34) & "\Microsoft\TaskName" & chr(34) & " /enable"
  .Run "schtasks.exe /run /tn " & chr(34) & "\Microsoft\TaskName" & chr(34)
  .Run "schtasks.exe /end /s server.domain.com /tn " & chr(34) & "\Microsoft\TaskName" & chr(34)
  .Run "schtasks.exe /change /s server.domain.com /tn " & chr(34) & "\Microsoft\TaskName" & chr(34) & " /disable"
End With

Online =  true
End Function
 
Function LooksAlive( )
LooksAlive = true
End Function
 
Function IsAlive( )
IsAlive = true
End Function
0
mmoya
Asked:
mmoya
  • 5
  • 2
1 Solution
 
merowingerCommented:
Create a scheduled task which gets executed as soon as a specific event gets logged in eventviewer.
I'm sure there's logged a event if a cluster resource fails
0
 
mmoyaAuthor Commented:
@merowinger: Thank you for the info. I know what you mean but we are dealing with a vendor app and this is the only sequence that'd work to bypass its limitations...

Is this correct?


Function Online( )

On Error Resume Next

Dim objShell : Set objShell = CreateObject("Wscript.Shell")

With objShell
  .Run "schtasks.exe /change /tn " & chr(34) & "\Microsoft\TaskName" & chr(34) & " /enable"
  .Run "schtasks.exe /run /tn " & chr(34) & "\Microsoft\TaskName" & chr(34)
  .Run "schtasks.exe /end /s server.domain.com /tn " & chr(34) & "\Microsoft\TaskName" & chr(34)
  .Run "schtasks.exe /change /s server.domain.com /tn " & chr(34) & "\Microsoft\TaskName" & chr(34) & " /disable"
End With

Online =  true
End Function
 
Function LooksAlive( )
LooksAlive = true
End Function
 
Function IsAlive( )
IsAlive = true
End Function
0
 
merowingerCommented:
sorry i do not understand. You want us to check the script or to get it run?!
3rd party Vendor app for what? A Cluster App?
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
mmoyaAuthor Commented:
@merowinger: I need to execute this command when the cluster resource fails...What is the right way of doing it... Thank you again.

Dim objShell : Set objShell = CreateObject("Wscript.Shell")

With objShell
  .Run "schtasks.exe /change /tn " & chr(34) & "\Microsoft\TaskName" & chr(34) & " /enable"
  .Run "schtasks.exe /run /tn " & chr(34) & "\Microsoft\TaskName" & chr(34)
  .Run "schtasks.exe /end /s server.domain.com /tn " & chr(34) & "\Microsoft\TaskName" & chr(34)
  .Run "schtasks.exe /change /s server.domain.com /tn " & chr(34) & "\Microsoft\TaskName" & chr(34) & " /disable"
End With
0
 
mmoyaAuthor Commented:
I got it... Should be

Function Online( )

On Error Resume Next

Dim objShell : Set objShell = CreateObject("Wscript.Shell")

With objShell
  .Run "schtasks.exe /change /tn " & chr(34) & "\Microsoft\Windows\TEST" & chr(34) & "

/enable"
  .Run "schtasks.exe /run /tn " & chr(34) & "\Microsoft\Windows\TEST" & chr(34)
End With

Online =  true
End Function
 
Function LooksAlive( )
LooksAlive = true
End Function
 
Function IsAlive( )
IsAlive = true
End Function

Function Offline( )
On Error Resume Next

Dim objShell : Set objShell = CreateObject("Wscript.Shell")
With objShell
 
  .Run "schtasks.exe /change /tn " & chr(34) & "\Microsoft\Windows\TEST" & chr(34) & "

/disable"
End With
End Function
0
 
mmoyaAuthor Commented:
.
0
 
mmoyaAuthor Commented:
I solved the issue.
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now