RvdH Posted January 20, 2006 Share Posted January 20, 2006 Is there a way i can check if a Windows Service, like Network Support is started before an auto-it app launches? RvdH Link to comment Share on other sites More sharing options...
pecloe Posted January 20, 2006 Share Posted January 20, 2006 hello everyone i am very interested in the same question. i've done searches till i'm blue in the face and all i come up with is quote If you have sc.exe in your system directory: CODE sc query "servicename" i have no idea how to use that! phil Link to comment Share on other sites More sharing options...
herewasplato Posted January 20, 2006 Share Posted January 20, 2006 (edited) See here:http://www.autoitscript.com/forum/index.php?showtopic=20001Edit:That post has a script that uses "Net Start" and another script that uses SC.exe....(and then there is the WMI method that can be found in other posts) Edited January 20, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
ChrisL Posted January 20, 2006 Share Posted January 20, 2006 hello everyonei am very interested in the same question. i've done searches till i'm blue in the face and all i come up with is quote If you have sc.exe in your system directory:CODE sc query "servicename" i have no idea how to use that!philIn CMD prompt if you type Net Start WorkstationIt tells you if the service is already started, I don't know any other way of doing it myself though [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
pecloe Posted January 20, 2006 Share Posted January 20, 2006 @herewasplato thank you! i don't think i'll ever figure out the search function on this great forum. phil Link to comment Share on other sites More sharing options...
herewasplato Posted January 21, 2006 Share Posted January 21, 2006 @herewasplatothank you! i don't think i'll ever figure out the search function on this great forum.philYou are welcome...RvdH,Did the code in that post work for you or do you need more info on the topic?...and BTW, welcome to the forum! [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
MHz Posted January 21, 2006 Share Posted January 21, 2006 SC.exe seems to only return Running services upon query, so the below code should be sufficient. This does use StdOutRead() from the AutoIt Beta.$stdout = Run('sc.exe query ' & $servicename, '', @SW_HIDE, 2) $data = _StdOut($stdout) Func _StdOut($stdout) Local $data While 1 $data = StdOutRead($stdout) If @error Then Return 'unknown' If $data Then If StringInStr($data, 'Running') Then Return 'Running' Else Sleep(10) EndIf WEnd EndFunc MsgBox(0, '', $data) Link to comment Share on other sites More sharing options...
RvdH Posted January 21, 2006 Author Share Posted January 21, 2006 (edited) Thanks 4 all your replies, seems i succesfully managed to determine the service state @herewasplato, i'm using the 2e (beta) example in that topic you posted, have to check if latest reply from MHz's way of doing it will work also Btw in the beta example from the other post the are 4 return codes, (1,2,3,4 where 4 is running) can you tell me the other values? Thx! RvdH Edited January 21, 2006 by RvdH Link to comment Share on other sites More sharing options...
herewasplato Posted January 21, 2006 Share Posted January 21, 2006 Btw in the beta example from the other post the are 4 return codes, (1,2,3,4 where 4 is running) can you tell me the other values?I'm not sure and I did not find a webpage that explains those states. You'll have to ask MHz - but I think that what he posted to this thread is just a better version of what he posted to the other thread: http://www.autoitscript.com/forum/index.ph...ndpost&p=138576In that other thread, MHz states:Edit: But perhaps searching for the string Running etc, would be more correct as the numbers would be the state for service startup, hmm.That is what he did in the code in this thread - searched for the word "running" in the output of the sc query...A little experimenting gives me 1 and 4:(and then there is 7)SERVICE_NAME: wzcsvc TYPE : 20 WIN32_SHARE_PROCESS STATE : 1 STOPPED (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0c:\>sc query wzcsvcSERVICE_NAME: wzcsvc TYPE : 20 WIN32_SHARE_PROCESS STATE : 4 RUNNING (STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0SERVICE_NAME: ShellHWDetection TYPE : 20 WIN32_SHARE_PROCESS STATE : 7 PAUSED (STOPPABLE,PAUSABLE,ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0later.... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
RvdH Posted January 21, 2006 Author Share Posted January 21, 2006 (edited) Ah, ok thx... another quick question though... can 2 If/Else/Endif statement be mixed with auto-it? My current script is not functioning after adding a 2e If/Else/Endif statement Like: If {this1} Then If {this2} Then Else Exit End if Else Exit End If RvdH Edited January 21, 2006 by RvdH Link to comment Share on other sites More sharing options...
ChrisL Posted January 21, 2006 Share Posted January 21, 2006 Ah, ok thx... another quick question though... can 2 if, else, endif statement be mixed with auto-it? Like: If {this1} Then If {this2} Then Else Exit End if Else Exit End If RvdH yes [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
RvdH Posted January 21, 2006 Author Share Posted January 21, 2006 (edited) yes Thats a quick answer as well ...but it doesn't fix the issue i having [Edit] Can someone see whats wrong with the post below? Edited January 21, 2006 by RvdH Link to comment Share on other sites More sharing options...
RvdH Posted January 21, 2006 Author Share Posted January 21, 2006 (edited) edited, look furter below Edited January 29, 2006 by RvdH Link to comment Share on other sites More sharing options...
herewasplato Posted January 22, 2006 Share Posted January 22, 2006 Had to download beta and the latest SciTE/Updates - via dialup no less. It works for me up to here: If StringInStr($data, 'Running') Then What exactly is it not doing for you... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
RvdH Posted January 22, 2006 Author Share Posted January 22, 2006 (edited) When the "Tcpip" service is checked and running the script works OK but whenever the "Tcpip" service is not running it popups the $answer MsgBox, After choosing "Yes" where the service should be started the executable just stops, allthough the code posted below should be executed...so either the program should be started or the MsgBox should popup...none of this happens btw, don't know if it matters but i'm using "v3.1.1.102" (shall try with latest build now) If FileExists(@SystemDir & "\BartPE.exe") Then RunWait(@ComSpec & " /c bartpe.exe -c p -i ms_tcpip", "", @SW_HIDE) RunWait(@ComSpec & " /c bartpe.exe -c c -i ms_msclient", "", @SW_HIDE) RunWait(@ComSpec & " /c " & 'net start "tcpip"', "", @SW_HIDE) RunWait(@ComSpec & " /c " & 'net start "dhcp"', "", @SW_HIDE) RunWait(@ComSpec & " /c regsvr32 /s /i ""%SystemDrive%\Programs\OO Software\Defrag Professional\oodpeo.ocx", "", @SW_HIDE) RunWait(@SystemDir & "\oodag.exe /service") RunWait(@ComSpec & " /c " & 'net start "O&O Defrag"', "", @SW_HIDE) RunWait($systemdrive & "\Programs\OO Software\Defrag Professional\oodcntrun.exe") RunWait(@ComSpec & " /c regsvr32 /s /u ""%SystemDrive%\Programs\OO Software\Defrag Professional\oodpeo.ocx", "", @SW_HIDE) RunWait(@SystemDir & "\oodag.exe /uninstall") RunWait(@ComSpec & " /c " & 'net stop "O&O Defrag"', "", @SW_HIDE) Exit Else MsgBox(48, "O&O Defrag Professional", "Bartpe.exe could not be found, O&O Defrag needs this file to start required services!") Exit Endif Edited January 22, 2006 by RvdH Link to comment Share on other sites More sharing options...
RvdH Posted January 22, 2006 Author Share Posted January 22, 2006 Same result with Beta v3.1.1.103... Link to comment Share on other sites More sharing options...
herewasplato Posted January 22, 2006 Share Posted January 22, 2006 (edited) change If $answer = 1 Then to If $answer = 6 Then ...let me know... edit: yes = 6 Edited January 22, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
RvdH Posted January 22, 2006 Author Share Posted January 22, 2006 Whoohoo, yes, that did it ! Thx, never could have find this on my own... RvdH 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