Jump to content

How to obtain status of remote process?


owensct
 Share

Recommended Posts

Hi All,

New to AutoIt and I am in the middle of writing a script to shutdown a database engine and then perform a backup of the database and restart the engine.

The script is supposed to check to see if the process is running and if it is then kill it. The problem I've run into is that I can't figure out how to check the status of the process on the remote computer. I know I can use ProcessExists() on the local machine, but is there a way or equivalent to obtain the process status on a remote system?

Rough steps to process are as follows:

If process is running then

Kill process

Backup database

Restart database engine

Wait 10 seconds

Verify that engine has started

Message Box “backup completed successfully”

Exit

Else

Message box Database is down please contact IS department

Exit

Any help would be greatly appreciated

Thanks

Gordon

Link to comment
Share on other sites

Search the web for psexec & pskill...look here for AutoIT references.

Thanks Varian,

I did finally figure it out. Here is the snippet of code I used in case anyone else has a similar question.

Case $BtnQ2 ; Starts daily backup process

$answer = MsgBox(4, "Daily Backup", "Have all users signed off the One Staff system?")

If $answer = 7 then

MsgBox(0," DataBase Backup", "Please ensure all users are logged off the System before continuing")

Else

$pid = Run('sc \\RemoteServer query "ServiceName"', '', @SW_HIDE, 2) ; Uses the Microsoft sc function

Do

$data &= StdOutRead($pid)

Until @error

If StringInStr($Data, 'running') then

RunWait('sc \\Servername stop "Pervasive.SQL (relational)"', '', @SW_HIDE, 2) ; if the service in question is running then stop it

RunWait('sc \\Servername stop "Pervasive.SQL (transactional)"', '', @SW_HIDE, 2) ;in my case I have two servicesd that need to be stopped

;Backup process goes here

RunWait('sc \\rhp-vms-001 start "Pervasive.SQL (relational)"', '', @SW_HIDE, 2) ;Restarts the service on the remote server

RunWait('sc \\rhp-vms-001 start "Pervasive.SQL (transactional)"', '', @SW_HIDE, 2) ;Restarts second service

Else

MsgBox(0,"One Staff Backup", "Database engine is down please contact the IS Department")

Exit

EndIf

Cheers,

Gordon

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...