Results 1 to 11 of 11

Thread: is "ANYONE" any good with services

  1. #1

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179

    is "ANYONE" any good with services

    I am officialy almost stuck. lol,



    Option Explicit
    Public iOpenScManagerResult As Long
    Public iOpenService As Long
    Public iGetServiceKeyNameResult As Long
    Public iLockServiceDatabaseResult As Long
    Public iUnlockServiceDatabaseResult As Long
    Public slpMachineName As String
    Public slpDatabaseName As String
    Public sServiceName As String
    Public slpServiceName As String
    Public srServiceName As String
    Public iLenServiceName As Long


    Private Sub Form_Load()
    sServiceName = "Dr Solomon's Task Manager" & Null

    'get service control number
    iOpenScManagerResult = OpenSCManager(slpMachineName, slpDatabaseName, SC_MANAGER_ALL_ACCESS)
    'lock service control database so that it can be modified
    iLockServiceDatabaseResult = LockServiceDatabase(iOpenScManagerResult)

    iGetServiceKeyNameResult = GetServiceKeyName(iOpenScManagerResult, sServiceName, srServiceName, iLenServiceName)
    MsgBox srServiceName
    iOpenService = OpenService(iOpenScManagerResult, srServiceName, SERVICE_ALL_ACCESS)

    're-open service control database
    iUnlockServiceDatabaseResult = UnlockServiceDatabase(iLockServiceDatabaseResult)
    End Sub
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  2. #2

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179
    the getservicekeyname isnt giving me a result, can anyone help??
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  3. #3
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    zip up the project and i'll see what I can do, for a fellow westcountryman (OOAARRR)...
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179
    i got a brand new vb project, an i'll give u the bugs
    Attached Files Attached Files
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  5. #5
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    you got 50 lines o' code

    and I got forty three.....

    Code:
    Private Sub Form_Load()
        srServiceName = String(256, " ")
        sServiceName = "SWEEP for Windows NT" & vbNullChar
        iLenServiceName = Len(sServiceName) + 1
        iOpenScManagerResult = OpenSCManager(slpMachineName, slpDatabaseName, SC_MANAGER_ALL_ACCESS)
        iGetServiceKeyNameResult = GetServiceKeyName(iOpenScManagerResult, sServiceName, srServiceName, iLenServiceName)
        MsgBox srServiceName
        iOpenService = OpenService(iOpenScManagerResult, srServiceName, SERVICE_ALL_ACCESS)
    End Sub
    it worked for me....

    BTW Cornwaaaall
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  6. #6

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179

    Post

    works a treat,

    i'll probably be posting again later tho, changeserviceconfig looms.

    lol

    thanks for the help
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  7. #7

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179

    ere we go again

    iChangeServiceConfigResult = ChangeServiceConfig(iOpenService, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, Null, Null, Null, Null, Null, "password" & vbNullChar, sServiceName)

    invalid use of null, <which one>, i tried following msdn and according to what i interpereted (laugh) i should have got it right. all i want to do is change the password.
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  8. #8
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Code:
        iChangeServiceConfigResult = ChangeServiceConfig(iOpenService, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, vbNullString, vbNullString, 0&, vbNullString, vbNullString, "password" & vbNullChar, sServiceName)
    I cant make it work cause I have no services which have passwords I can change, but this might work.....
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  9. #9
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    heres a C++ sample from MSDN, but it shows you the right order in which tomake the calls, and also the right flags to use,
    Attached Files Attached Files
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  10. #10
    Hyperactive Member LeeSalter's Avatar
    Join Date
    Oct 2002
    Location
    Notts, England
    Posts
    307
    hi all,

    I am trying to manipulate NT Services and have got this piece of code...

    VB Code:
    1. Declare Function ChangeServiceConfig Lib "advapi32.dll" Alias "ChangeServiceConfigA" _
    2. (ByVal hService As Long, ByVal dwServiceType As Long, _
    3. ByVal dwStartType As Long, ByVal dwErrorControl As Long, _
    4. ByVal lpBinaryPathName As String, ByVal lpLoadOrderGroup As String, _
    5. lpdwTagId As Long, ByVal lpDependencies As String, ByVal lpServiceStartName As String, _
    6. ByVal lpPassword As String, ByVal lpDisplayName As String) As Long

    ...in my declarations.
    I use this code to change the configuration of a particular service to automatically start....

    VB Code:
    1. lConfigResult = ChangeServiceConfig(lhService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, vbNullString, vbNullString, 0&, vbNullString, vbNullString, vbNullString, service)

    ...but I get an error 87 .. Invalid Parameter.

    I have opened the service successfully as I can view properties on it (ie is it running etc).

    any ideas???
    "I'm Brian and so is my Wife"

  11. #11

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179
    sorry, it was quite a while ago ...

    i dont think it was ever completed ... i kept locking the database every time i tried changing the settings
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width