yehia Posted December 3, 2008 Share Posted December 3, 2008 i was trying to test creating a service and i though it worked untill i tested my script for a time longer than 30 secs im not using the srvany.exe file im using the Service.au3 and 2 functions from ServiceControl.au3 when i tried to start the service from Services.msc i got this error "Error 1053 : the service did not respond to the start or control request in a timely fashion" i searched the forum found topics but no solutions this is my script i hope someone can help without the use of srvany.exe (the script will start the service and close it self to leave the script work as a service) expandcollapse popup#include <Service.au3> $sServiceName = "blah" If Not _ServiceExists("", $sServiceName) Then _Service_Create("", $sServiceName, "blah", '"' & @ScriptFullPath & '"') _StartService("", $sServiceName) Exit EndIf Do Sleep(1000) Beep(1000,100) Until 1 = 5 Func _StartService($sComputerName, $sServiceName) Local $hAdvapi32 Local $hKernel32 Local $arRet Local $hSC Local $hService Local $lError = -1 $hAdvapi32 = DllOpen("advapi32.dll") If $hAdvapi32 = -1 Then Return 0 $hKernel32 = DllOpen("kernel32.dll") If $hKernel32 = -1 Then Return 0 $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _ "str", $sComputerName, _ "str", "ServicesActive", _ "long", $SC_MANAGER_CONNECT) If $arRet[0] = 0 Then $arRet = DllCall($hKernel32, "long", "GetLastError") $lError = $arRet[0] Else $hSC = $arRet[0] $arRet = DllCall($hAdvapi32, "long", "OpenService", _ "long", $hSC, _ "str", $sServiceName, _ "long", $SERVICE_START) If $arRet[0] = 0 Then $arRet = DllCall($hKernel32, "long", "GetLastError") $lError = $arRet[0] Else $hService = $arRet[0] $arRet = DllCall($hAdvapi32, "int", "StartService", _ "long", $hService, _ "long", 0, _ "str", "") If $arRet[0] = 0 Then $arRet = DllCall($hKernel32, "long", "GetLastError") $lError = $arRet[0] EndIf DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hService) EndIf DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC) EndIf DllClose($hAdvapi32) DllClose($hKernel32) If $lError <> -1 Then SetError($lError) Return 0 EndIf Return 1 EndFunc Func _ServiceExists($sComputerName, $sServiceName) Local $hAdvapi32 Local $arRet Local $hSC Local $bExist = 0 $hAdvapi32 = DllOpen("advapi32.dll") If $hAdvapi32 = -1 Then Return 0 $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _ "str", $sComputerName, _ "str", "ServicesActive", _ "long", $SC_MANAGER_CONNECT) If $arRet[0] <> 0 Then $hSC = $arRet[0] $arRet = DllCall($hAdvapi32, "long", "OpenService", _ "long", $hSC, _ "str", $sServiceName, _ "long", $SERVICE_INTERROGATE) If $arRet[0] <> 0 Then $bExist = 1 DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $arRet[0]) EndIf DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC) EndIf DllClose($hAdvapi32) Return $bExist EndFunc My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine Link to comment Share on other sites More sharing options...
enaiman Posted December 3, 2008 Share Posted December 3, 2008 Have a look Here - it shows how to create a service without using srvany.Good luck, SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
yehia Posted December 9, 2008 Author Share Posted December 9, 2008 u got me all wrong, i mean how to make my script work well or whats the mistake on it i dont want to use external exes thanks alot for ur help and its appreciated My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine Link to comment Share on other sites More sharing options...
Developers Jos Posted December 9, 2008 Developers Share Posted December 9, 2008 (edited) u got me all wrong, i mean how to make my script work well or whats the mistake on iti dont want to use external exesthanks alot for ur help and its appreciatedYou cannot just run a program as service unless it adheres to the defined standards for Service programs. You need a helper exe like srvany.exe to be able to run a "regular" exe as service. Edited December 9, 2008 by Jos SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
yehia Posted December 9, 2008 Author Share Posted December 9, 2008 thanks for ur answer Josthis topic is about registering a service without external files http://www.autoitscript.com/forum/index.ph...c=80201&hl=im trying to get this topic writer support and here tooi supported my script above it works but it times out after 30 secs dont know why and how to make it work weel My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine Link to comment Share on other sites More sharing options...
yehia Posted December 13, 2008 Author Share Posted December 13, 2008 bump ... My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine Link to comment Share on other sites More sharing options...
enaiman Posted December 14, 2008 Share Posted December 14, 2008 It looks like you're bumping your post everyday by deleting/reposting your last reply (actually you've been doing that since you started the thread). If you haven't got any useful replies by now there is a small chance that you will get any. Re-bumping endlessly your thread can be considered rude even if it is not violating this forum's TOS. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) 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