fcjoe Posted October 3, 2012 Share Posted October 3, 2012 Hello, I have a compiled script that runs with no problems when I run it manually. I used the SC command to add it as a service but when I try to start it I get an error. Error: 1503: The service did not responds to the start control request in a timely fashion. This is the first time I've tried adding one of my scripts as a service. Is there something I need to add to the code to send a signal to windows that it has started successfully? Or is something else causing this issue? If you need the code let me know and I will post it. Thanks, Joe Link to comment Share on other sites More sharing options...
guinness Posted October 3, 2012 Share Posted October 3, 2012 What command do you use for SC? What version of AutoIt? Windows? And have you tried one the UDFs in the Examples section to create a service. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 3, 2012 Moderators Share Posted October 3, 2012 To guinness' points I would add, always post your code (or at least a reproducer). It really should be a pre-requisite for creating a thread, and will help us help you "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
fcjoe Posted October 3, 2012 Author Share Posted October 3, 2012 What command do you use for SC? What version of AutoIt? Windows? And have you tried one the UDFs in the Examples section to create a service.Guinness,AutoIt 3.3.6.1Windows 7 64BitSC command: sc create ManageWireless binPath= D:CodeWirelessManageWireless.exeHave not tried one of the examples but I will try that now and report back. Link to comment Share on other sites More sharing options...
fcjoe Posted October 3, 2012 Author Share Posted October 3, 2012 (edited) Here is my code, basically copied the VBScript from link below and recoded for AutoIt http://gallery.technet.microsoft.com/scriptcenter/Disable-wireless-f3bcf66f expandcollapse popupDim $objWMIService Dim $colLAN, $colWiFi Dim $objWiFi, $objLAN Dim $strWirelessName Dim $State = "" Dim $wireStatus = "" Dim $wifiStatus = "" ;Dim $oVBS $oVBS = ObjCreate("ScriptControl") $oVBS.language = "VBScript" Global Const $Nothing = $oVBS.eval("Nothing") $oVBS = $Nothing While 1 $strWirelessName = GetWirelessName() $objWMIService = ObjGet("winmgmts:.rootCIMV2") $colLAN = $objWMIService.ExecQuery("Select * From Win32_NetworkAdapter Where NetConnectionID like 'Local Area Connection' and PhysicalAdapter='True'") $colWiFi = $objWMIService.ExecQuery ("Select * From Win32_NetworkAdapter Where NetConnectionID =" & "'" & $strWirelessName & "'" & " and PhysicalAdapter='True'") For $objWiFi In $colWiFi If $objWiFi.Netconnectionstatus = 2 Then $wifiStatus = True ;MsgBox(0,"","WiFi Connected") Else $wifiStatus = False ;MsgBox(0,"","WiFi DIS-Connected") EndIf Next For $objLAN in $colLAN If $objLAN.Netconnectionstatus=2 Then $wireStatus = True ;$State = False ;this is very importnat variable to determine when to enable or disbale wireless connection Else $wireStatus = False EndIf Next If $wireStatus = False And $wifiStatus = False Then EnableWireless($strWirelessName) ElseIf $wireStatus = True And $wifiStatus = True Then DisableWireless($strWirelessName) EndIf Sleep(5000) WEnd Func GetWirelessName() Local $strKeyPath = "SYSTEMCurrentControlSetControlNetwork{4D36E972-E325-11CE-BFC1-08002BE10318}" Local $objReg Local $arrSubKeys[25] Local $SubKey Local $strValueName Local $dwValue Local $strValue Local $intRet Const $HKLM = 0x80000002 $objReg = ObjGet("winmgmts:.rootdefault:StdRegProv") $objReg.Enumkey($HKLM ,$strKeyPath,$arrSubKeys) For $SubKey In $arrSubKeys $strValueName = "MediaSubType" $objReg.GetDWORDValue($HKLM,$strKeyPath & "" & $SubKey & "" & "Connection",$strValueName,$dwValue) If $dwValue = 2 Then $strValueName = "Name" $objReg.GetStringValue($HKLM,$strKeyPath & "" & $SubKey & "" & "Connection",$strValueName,$strValue) ExitLoop EndIf Next Return($strValue) EndFunc Func EnableWireless($strNetConn) Local $objShell, $colConnections, $objConn, $objNetwork, $objEnable, $objVerb Local $strEnable = "En&able" Const $NETWORK_CONNECTIONS = 0x31 $objShell = ObjCreate("Shell.Application") $colConnections = $objShell.Namespace($NETWORK_CONNECTIONS) For $objConn In $colConnections.Items If $objConn.Name = $strNetConn Then $objNetwork = $objConn ExitLoop EndIf Next $objEnable = $Nothing ;Enable NIC For $objVerb In $objNetwork.verbs If $objVerb.name = $strEnable Then $objEnable = $objVerb ExitLoop EndIf Next If $objEnable <> $Nothing Then $objEnable.DoIt Sleep(60000) EndFunc Func DisableWireless($strNetConn) Local $objShell, $colConnections, $objConn, $objNetwork, $objDisable, $objVerb Local $strDisable = "Disa&ble" Const $NETWORK_CONNECTIONS = 0x31 $objShell = ObjCreate("Shell.Application") $colConnections = $objShell.Namespace($NETWORK_CONNECTIONS) For $objConn in $colConnections.Items If $objConn.Name = $strNetConn Then $objNetwork = $objConn ExitLoop EndIf Next $objDisable = $Nothing For $objVerb in $objNetwork.verbs if $objVerb.name = $strDisable Then $objDisable = $objVerb ExitLoop EndIf Next If $objDisable <> $Nothing Then $objDisable.DoIt Sleep(3000) EndFunc Edited October 3, 2012 by fcjoe Link to comment Share on other sites More sharing options...
fcjoe Posted October 3, 2012 Author Share Posted October 3, 2012 I used an example (write to file) compiled it, added as a service and when I started it got the same error. Link to comment Share on other sites More sharing options...
CoreTech Posted October 7, 2012 Share Posted October 7, 2012 Simply using SC to add your application won't work since your app isn't a native Windows Service. Error 1053 comes up because Windows is sending a "start" command but your application doesn't know how to handle it...You need a "service wrapper" that will intercept the Windows Service start command and kick off your application (as if you had double-clicked on it yourself). Microsoft provides Srvany for free, but there are other more robust commercial alternatives like the one our company makes (AlwaysUp).Note - you may have trouble with some of the AutoIt functions (like WinActivate and WinWaitActive) when running as a Windows Service. Search the forum to find out more. Link to comment Share on other sites More sharing options...
water Posted October 7, 2012 Share Posted October 7, 2012 is an UDF that lets your scripts run as a service. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
fcjoe Posted October 9, 2012 Author Share Posted October 9, 2012 is an UDF that lets your scripts run as a service.I went to that link, but the first line is "Don't use this in production environment !" I plan on running this on all computers in my company. Link to comment Share on other sites More sharing options...
water Posted October 9, 2012 Share Posted October 9, 2012 Version 1 of the UDF (can be found at the bottom of the first post) has about 5600 downloads, version 2 (the one at the top of the first post) about 1200. I think you can trust this UDF. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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