Sign in to follow this  
Followers 0
owensct

How to obtain status of remote process?

3 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Edited by Varian

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0