Find out if swremote is running?

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
wetwired
Member
Posts: 85
Joined: Thu Jun 19, 2003 7:33 am

Find out if swremote is running?

Post by wetwired »

Is there a way for Housebot to know if a swremote is running? I want a task to start the swremote if it has been closed for a certain time...
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Find out if swremote is running?

Post by roussell »

There isn't a native way in HB as far as I know, you can launch a application on a remote PC using vbscript, but I don't believe there is a way with raw VBscript to tell if an app is running unless it's possible with a WshShell.AppActivate call, but that's just a guess. I'll play with it a little and see if I can come up with anything. To run an app remotely, you'd execute something like this in a script on the HB server - note that you'll need to be an admin on the remote computer and you may have problems with Vista - XP works much better.

Code: Select all

a=GetObject("winmgmts:\\" & (Remote_Computer) & "\root\cimv2:Win32_Process").Create("Path_to_SWREMOTE", null, null, intProcessID)
Terry
wetwired
Member
Posts: 85
Joined: Thu Jun 19, 2003 7:33 am

Re: Find out if swremote is running?

Post by wetwired »

I don´t need to open the swremote on a remote computer at this moment, I´m running the server and swremote on the same box. But thanks for the tip, I´ll look into the WshShell.AppActivate call and see if I can get something to work.
roussell
Advanced Member
Posts: 268
Joined: Wed Dec 15, 2004 9:07 am
Location: Pelham, AL

Re: Find out if swremote is running?

Post by roussell »

See if you can use this - save it as a .vbs and run it external to HouseBot. It will ask for the name of the executable and then for the name of the computer to check. It will then either return running or not running. You can specify the computer name that the script is on (localhost) or a remote computer if you have admin rights to it...

Code: Select all

Function IsProcessRunning( strServer, strProcess )
    Dim Process, strObject
    IsProcessRunning = False
    strObject   = "winmgmts://" & strServer
    For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
      If UCase( Process.name ) = UCase( strProcess ) Then
            IsProcessRunning = True
            Exit Function
        End If
    Next
End Function

Dim strComputer, strProcess
Do
   strProcess = inputbox( "Please enter the name of the process (for instance: notepad.exe)", "Input" )
Loop until strProcess <> ""
Do
   strComputer = inputbox( "Please enter the computer name", "Input" )
Loop until strComputer <> ""
If( IsProcessRunning( strComputer, strProcess ) = True ) Then
    WScript.Echo "Process " & strProcess & " IS running on computer " & strComputer
Else
    WScript.Echo "Process " & strProcess & " is NOT running on computer " & strComputer
End If
If it works for you then you can use this as a starting point for creating the HB script you're looking for.

Terry
wetwired
Member
Posts: 85
Joined: Thu Jun 19, 2003 7:33 am

Re: Find out if swremote is running?

Post by wetwired »

Thank you, I modified the script to suit my needs, a timer and a task runs the script at regular intervals.

Code: Select all

Dim Process, strObject
strObject   = "winmgmts://kontrollpc"
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( "swremote.exe" ) Then
isrunning="yes"
End If
Next

if isrunning="yes" then
else
set objShell=CreateObject("Wscript.Shell")
objShell.Run("c:\\program\swremote\swremote.exe") 
end if

SetPropertyValue "Timer kolla om swremote är igång.Running", "Yes"
Post Reply