SERVICE_STATE_ALL = (SERVICE_ACTIVE + SERVICE_INACTIVE) SERVICEERRORCONTROL_NO_CHA NGE = SERVICE_NO_CHANGE MsidbServiceInstallErrorCo ntrolVital = &H8000 SERVICESTARTTYPE_NO_CHANGE = SERVICE_NO_CHANGE SERVICETYPE_NO_CHANGE = SERVICE_NO_CHANGE Public Const SERVICE_NO_CHANGE = &HFFFFFFFF Public Const ERROR_INSUFFICIENT_BUFFER = 122 Public Const STANDARD_RIGHTS_REQUIRED = &HF0000 Is there any other way to have a window service change its own recovery parameters (preferablly without useĪll of the Const, structures and enum are listed below: Is it possible to call ChangeServiceConfig2 in my Main routine or does it have to be called in an installer? This is often an indication that other memory is corrupt." "Attempted to read or write protected memory. I get a AccessViolationException at my call to OpenService: OpenSCManager and LockServiceDatabase both return a good handle. I call ChangeRecoveryNow with ServiceName = "xyz" and SystemName = null (which should default to local system.) Result = ChangeServiceConfig2(hSVC, InfoLevel.SERVICE_CONFIG_F AILURE_ACT IONS, IPInfo) HSVC = OpenService(hSCM, ServiceName, ACCESS_TYPE.SERVICE_ALL_AC CESS) HSCM = OpenSCManager(SystemName, vbNullString, ServiceControlManagerType. SCActionType = SC_ACTION_TYPE.SC_ACTION_R ESTART Public Shared Function ChangeRecoveryNow(ServiceN ame As String, SystemName As String) As String Private Sub TimerMain_Elapsed(sender As Object, e As Timers.ElapsedEventArgs) Handles TimerMain.ElapsedĬall Main_Entry() <-ChangeRecoveryNow is called in here.not in a project installer routine! Protected Overrides Sub OnStart(ByVal args() As String) (I listed all the Declares, Const, sturctures and ENUMs found in recovery down below.) I found the code below and placed it into a class called recovery. "first/second/subsequent Failure" to "Restart the Service" The recovery parameters i'm talking about are those found in:Ĭomputer Management > Services and Applications > lect a service name, right click and I don't have (or want) a project installer (at this time.) Most of the examples of using ChangeServiceConfig2 talk of using it in a project installer routine. I have found serval examples and the majority use ChangeServiceConfig2 to accomplish this task. I start my service using a batch file and cmd: I want to add code to this window service so it (itself) can change its own recovery parameters. I have created a windows service using vs2012, vb.net 4.0 (which works fine.)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |