Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generic Script to use WScript.exe in Cluster

Status
Not open for further replies.

cspm2003

Programmer
Nov 24, 2004
78
DE
Hi, I made a topic earlier, but I found out that theres nothing wrong with my script, but more the way server2k3 handels it I think. I got a line in my Script:

Code:
Set objArgs = WScript.Arguments

which works fine if I run the script manually, but if a generic script gets executed from the cluster it doesnt seam like wscript.exe handels the script. Can I somehow tell it to use wscript.exe instead of what ever it uses now to execute my script?

help is greatfully appreciated.

cheers
 
Add this to the top of your script:

Code:
Dim oShell
Set oShell = CreateObject("Wscript.Shell")

forceUseWScript

Sub forceUseWScript()
   If Not WScript.FullName = WScript.Path & "\wscript.exe" Then
      oShell.Popup "Launched using cscript. Relaunching...",3,"CSCRIPT"
      oShell.Run "cmd.exe /k " & WScript.Path & "\wscript.exe //NOLOGO " & Chr(34) & WScript.scriptFullName & Chr(34),1,False
      WScript.Quit 0
   End If
End Sub

I hope you find this post helpful.

Regards,

Mark
 
You want me to add this at the very top where the variable decleration is, right?

If I try to turn the resource online, I get an error. In the cluster.log it say:

Runtimeerror in VBScript on Line6, Character 6
Object required: 'WScript'

thx

 
You did save this as a VBS file right?

I hope you find this post helpful.

Regards,

Mark
 
yes, my vbs file structure looks like this:

Code:
Dim oShell
Set oShell = CreateObject("Wscript.Shell")

forceUseWScript

Sub forceUseWScript()
   If Not WScript.FullName = WScript.Path & "\wscript.exe" Then
      oShell.Popup "Launched using cscript. Relaunching...",3,"CSCRIPT"
      oShell.Run "cmd.exe /k " & WScript.Path & "\wscript.exe //NOLOGO " & Chr(34) & WScript.scriptFullName & Chr(34),1,False
      WScript.Quit 0
   End If
End Sub 

Sub Open( )
End Sub

Function Close( )
End Function

Function Online( )
End Function

Function Offline( )
End Function

Function Terminate( )
End Function

Function LooksAlive( )
End Function

Function IsAlive( )
End Function

its saved as execApp.vbs
 
OK, that looks alright, how are you executing it?

I hope you find this post helpful.

Regards,

Mark
 
In the cluster administrator, I created a new Generic Resource, as Dependencies I added:

-IP Address
-Physical Disk

and I supplyed the path to the script.

Heres the complete Script:
Code:
Function Open( )
End Function

Function Online( )
dim ShellWSH
dim CommandToExecute
Set ShellWSH = CreateObject("WScript.Shell")
CommandToExecute = "C:\Programme\tomcat\bin\startup.bat"
ShellWSH.Run CommandToExecute
wscript.sleep 15000
Online = True
End Function

Function LooksAlive( )
ProcessName= "notepad.exe"
ServerName= "wuno-messmer1"

looksAlive = false
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & ServerName &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_Process",,48)

For Each objItem in colItems
if objItem.Name =ProcessName then
LooksAlive = True
end if
Next
End Function

Function IsAlive( )
objArgs WScript.Arguments

ProcessName= "notepad.exe"
instance= "1"
ServerName= "wuno-messmer1"
IsAlive = False

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & ServerName &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_Process",,48)

For Each objItem in colItems
if objItem.Name =ProcessName then
        IsAlive = True
end if
Next
End Function

Function Offline( )
End Function

Function Close( )
End Function

Function Terminate( )
End Function

I tryed putting the Online() and LooksAlive() function in seperate vbs files and executed them manually and that worked fine with no errors
 
Sorry, I don't think I can be of more help on this one. :-(

I hope you find this post helpful.

Regards,

Mark
 
just as an update if your interested:

I managed to get it working by writing a vb6 app that start/stops the application.

now it work :D
 
Glad you got it resolved.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top