fatsheldon
Programmer
hi, i'm trying to change password for the account that a service uses at startup. much like the MSDN example "Changing the Password on a Service's User Account" except in VB not C.
I can OpenSCManager, OpenService and LockServiceDatabase with no problems, but ChangeServiceConfig always fails. here's my statements:
Declare Function ChangeServiceConfig Lib "advapi32.dll" Alias "ChangeServiceConfigA" (ByVal hService As Long, ByVal dwServiceType As Long, ByVal dwStartType As Long, ByVal dwErrorControl As Long, ByVal lpBinaryPathName As String, ByVal lpLoadOrderGroup As String, lpdwTagId As Long, ByVal lpDependencies As String, ByVal lpServiceStartName As String, ByVal lpPassword As String, ByVal lpDisplayName As String) As Long
errCode = ChangeServiceConfig(svcHandle, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, _
vbNullString, vbNullString, 0&, vbNullString, vbNullString, "NewPassword13", vbNullString)
If errCode = 0 Then
MsgBox "LastDllError = " & CStr(Err.LastDllError)
UnlockServiceDatabase ByVal scmLock
CloseServiceHandle (svcHandle)
CloseServiceHandle (scMan)
setServicePasswd = 2
Exit Function
End If
I've managed to get lastdllerror 87 (invalid parameter?) and 997 (IO pending?).
Does anyone have example VB code on exactly how to call this function and/or the exact value i should be using for SERVICE_NO_CHANGE ?
This is frustrating me quite a bit. ok, a lot.
I can OpenSCManager, OpenService and LockServiceDatabase with no problems, but ChangeServiceConfig always fails. here's my statements:
Declare Function ChangeServiceConfig Lib "advapi32.dll" Alias "ChangeServiceConfigA" (ByVal hService As Long, ByVal dwServiceType As Long, ByVal dwStartType As Long, ByVal dwErrorControl As Long, ByVal lpBinaryPathName As String, ByVal lpLoadOrderGroup As String, lpdwTagId As Long, ByVal lpDependencies As String, ByVal lpServiceStartName As String, ByVal lpPassword As String, ByVal lpDisplayName As String) As Long
errCode = ChangeServiceConfig(svcHandle, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, _
vbNullString, vbNullString, 0&, vbNullString, vbNullString, "NewPassword13", vbNullString)
If errCode = 0 Then
MsgBox "LastDllError = " & CStr(Err.LastDllError)
UnlockServiceDatabase ByVal scmLock
CloseServiceHandle (svcHandle)
CloseServiceHandle (scMan)
setServicePasswd = 2
Exit Function
End If
I've managed to get lastdllerror 87 (invalid parameter?) and 997 (IO pending?).
Does anyone have example VB code on exactly how to call this function and/or the exact value i should be using for SERVICE_NO_CHANGE ?
This is frustrating me quite a bit. ok, a lot.