Page 1 of 1

Find out if swremote is running?

Posted: Wed Sep 30, 2009 2:27 pm
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...

Re: Find out if swremote is running?

Posted: Thu Oct 01, 2009 8:36 am
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

Re: Find out if swremote is running?

Posted: Thu Oct 01, 2009 8:46 am
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.

Re: Find out if swremote is running?

Posted: Thu Oct 01, 2009 9:16 am
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

Re: Find out if swremote is running?

Posted: Fri Oct 02, 2009 5:01 am
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"