r4b1dm0nk3y Posted June 2, 2011 Share Posted June 2, 2011 Hi all, I'm looking to convert a batch script into AutoIT. Basically this script checks the state of the service, then stops it if it is running or starts if stopped. Below is the batch code. I'm not looking to do a _RunDOS or Run() function but to have a true AutoIT script. I'm new to AutoIT but I want to start off good and proper. I'm planing to integrate this somehow to another .au3 which I've created to execute mouse clicks. Any help is appreciated. @echo off FOR /F "tokens=1,2,3,4" %%A IN ('SC.EXE QUERY "<Service Name Here>" ^| FIND /I "STATE"') DO SET STATE=%%D IF /I "%STATE%"=="RUNNING" (NET STOP "<Service Name Here>") ELSE (NET START "<Service Name Here>") FOR /F "tokens=1,2,3,4" %%A IN ('SC.EXE QUERY "<Service Name Here>" ^| FIND /I "STATE"') DO SET STATE=%%D IF /I "%STATE%"=="RUNNING" (NET STOP "<Service Name Here>") ELSE (NET START "<Service Name Here>") FOR /F "tokens=1,2,3,4" %%A IN ('SC.EXE QUERY "<Service Name Here>" ^| FIND /I "STATE"') DO SET STATE=%%D IF /I "%STATE%"=="RUNNING" (NET STOP "<Service Name Here>") ELSE (NET START "<Service Name Here>") Link to comment Share on other sites More sharing options...
Cybergon Posted June 2, 2011 Share Posted June 2, 2011 Here Also welcome! Link to comment Share on other sites More sharing options...
r4b1dm0nk3y Posted June 7, 2011 Author Share Posted June 7, 2011 Thanks Cybergon.I don't know if that will work though. Correct me if I'm wrong but that script will only suspend and resume a process. That is not the same as starting and stopping the service correct? If my service parses files in a directory upon start, If I suspend it and resume it will it parse those files again as if the process has just been started? Perhaps thats a question for the software developer but I guess my underlying question is does suspending and resuming act the same as stopping and starting? Link to comment Share on other sites More sharing options...
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