Search the Community
Showing results for tags 'restart service'.
-
Dear reader, I'm a little stuck in writting the script I want to build. The anoying thing is : I know how to do it myself but not how to build it. When u see the code u will understand what i mean The mean problem is that i don't know how to use command line in[puts in autoit. When is searching the help files of autoit i dint find anything usefull I hope there is somebody that will push me in the right direction for building this "simple" code (read: not for me that simple since I'm exploring Autoit ) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### Form $Form1 = GUICreate("Services restarter", 381, 205, 192, 114) $ButtonServ1 = GUICtrlCreateButton("Restart services 1", 224, 32, 121, 33) $ButtonServ2 = GUICtrlCreateButton("Restart services 2", 224, 80, 121, 33) $ButtonServ3 = GUICtrlCreateButton("Restart services 3", 224, 128, 121, 33) $Group1 = GUICtrlCreateGroup("Services", 208, 16, 153, 169) GUICtrlCreateGroup("", -99, -99, 1, 1) $ButtonCancel = GUICtrlCreateButton("Cancel", 40, 144, 121, 33) $LUsername = GUICtrlCreateLabel("Username", 16, 40, 52, 17) $IUsername = GUICtrlCreateInput("", 96, 40, 89, 21) $IPassword = GUICtrlCreateInput("", 96, 80, 89, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $LPassword = GUICtrlCreateLabel("Wachtwoord", 16, 80, 65, 17) $Group2 = GUICtrlCreateGroup("Credentials", 8, 16, 185, 113) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### end Form While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $ButtonCancel Exit case $ButtonServ1 Local $var = Ping("Computer1", 250) If $var Then #comments-start command line inputs sc \\Computer1 stop Service1 sc \\Computer1 query Service1 if service1 stopped then sc \\Computer1 stop Service2 sc \\Computer1 query Service2 if service2 stopped then sc \\Computer1 stop Service3 sc \\Computer1 query Service3 if service3 stopped then sc \\Computer1 start Service1 sc \\Computer1 query Service1 if service1 started then sc \\Computer1 start Service2 sc \\Computer1 query Service2 if service2 started then sc \\Computer1 start Service3 sc \\Computer1 query Service3 if service3 started then #comments-end Else MsgBox(0, "Status", "An error occured with number: " & @error & @CRLF & "1 = Host is offline"& @CRLF & "2 = Host is unreachable"& @CRLF & "3 = Bad destination"& @CRLF & "4 = Other errors or also unreachable") EndIf EndSwitch WEnd