Jass Posted December 1, 2009 Posted December 1, 2009 (edited) Hey all, I wrote a script to backup a MS SQL database and some files to another directory. My question is how is it possible to wait until the MS SQL service is stopped before continuing the script and copying the database and the other files. I tried to realize this with a while loop but i doesn't work. This is the part of the script which doesn't want to work as I want it to: ;Shutdown SQL-Server _RunDOS("sc stop " & $sqlinstancename) $statusservice = _Service_QueryStatus($sqlinstancename) While $statusservice[1] <> 1 Sleep(5000) WEnd For the function _Service_QueryStatus I use the UDF Services.au3, the function returns 1 for Array[1] if service is stopped. If Service isn't stopped I want the script to wait five seconds until rechecking the state. But this doesn't work Thanks for help. Jass Edited December 1, 2009 by Jass
Juvigy Posted December 1, 2009 Posted December 1, 2009 (edited) The easiest i can thing of is to use RunWait to stop the service . @edit Scratch that it doesnt work - the CMD command doesnt wait until the service is stopped to complete and exit. Edited December 1, 2009 by Juvigy
99ojo Posted December 1, 2009 Posted December 1, 2009 (edited) Hi, you have to refresh the $statusservice in between the While loop, otherwise it won't change and loop for ever: $statusservice = _Service_QueryStatus($sqlinstancename) While $statusservice[1] <> 1 Sleep(5000) $statusservice = _Service_QueryStatus($sqlinstancename) WEnd ;-)) Stefan Edited December 1, 2009 by 99ojo
Jass Posted December 1, 2009 Author Posted December 1, 2009 Hi,you have to refresh the $statusservice in between the While loop, otherwise it won't change and loop for ever:;-))StefanGreat!Thanks man und schöne Grüße nach Bonn
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now