Help with 'NT Service' VB Control 
Author Message
 Help with 'NT Service' VB Control

(The following is virtually a copy of examples I've found on MSDN sites)

What's wrong with this, as when I install (command="-install") it fails on line 21
Note: The error handling (mine) works ok.

'start*****************
Private Sub Form_Load()
10 Dim strLogText As String
11 Const METHOD_NAME = "frmQ.Form_Load"

13 On Error GoTo ErrorTrap
14 Me.timOut.Enabled = False

16 With Me.srvNTService
17     If Command = "-install" Then
18         .Interactive = True
19         .DisplayName = .DisplayName & " " & App.Major & "." &
App.Minor & "." & App.Revision
20         If Not .Install Then
21             Err.Raise FATAL_ERROR, , "Unable to start service -
failed to install"
22         End If
23         strLogText = "New Business Triggers installed"
24     Else
25         If Command$ = "-uninstall" Then
26             If Not .Uninstall Then
27                 Err.Raise FATAL_ERROR, , "Failed to uninstall"
28             End If
29             'Unload Me
30             strLogText = "New Business Triggers uninstalled"
31         End If
32     End If
33     .ControlsAccepted = 2
34     .StartService
35 End With

37 If strLogText <> "" Then
38     ' Log to NB journal
39     JournalQWrite _
        METHOD_NAME, _
        "Status", _
        strLogText

44     ' Log tot NT event viewer
45     Me.srvNTService.LogEvent _
        svcMessageInfo, _
        svcEventInformation, _
        strLogText
49 End If
50 Me.Hide

52 Exit Sub
53 ErrorTrap:
54     ReportError METHOD_NAME

End Sub

'end ******************
Thanks in advance

Dan



Sat, 07 Aug 2004 16:46:15 GMT  
 Help with 'NT Service' VB Control
Not sure if this will help but there is actually a bug in the NTSvc control.
If you try to install a service that is already installed, it fails.
I have fixed this and recompiled the control and works just fine now. If you
want I can e-mail you the fixed source file (or the ocx if you prefer).

Also note that if you specify the account to use for starting the service,
you have to use the full syntax (domain\username) and not just the username
(this is not a bug of course).

--
Panayotis Kouvarakis
R&D Manager
Datagraf S.A.
phone: +30 (1) 09573008
fax:      +30 (1) 09574657


Quote:
> (The following is virtually a copy of examples I've found on MSDN sites)

> What's wrong with this, as when I install (command="-install") it fails on
line 21
> Note: The error handling (mine) works ok.

> 'start*****************
> Private Sub Form_Load()
> 10 Dim strLogText As String
> 11 Const METHOD_NAME = "frmQ.Form_Load"

> 13 On Error GoTo ErrorTrap
> 14 Me.timOut.Enabled = False

> 16 With Me.srvNTService
> 17     If Command = "-install" Then
> 18         .Interactive = True
> 19         .DisplayName = .DisplayName & " " & App.Major & "." &
> App.Minor & "." & App.Revision
> 20         If Not .Install Then
> 21             Err.Raise FATAL_ERROR, , "Unable to start service -
> failed to install"
> 22         End If
> 23         strLogText = "New Business Triggers installed"
> 24     Else
> 25         If Command$ = "-uninstall" Then
> 26             If Not .Uninstall Then
> 27                 Err.Raise FATAL_ERROR, , "Failed to uninstall"
> 28             End If
> 29             'Unload Me
> 30             strLogText = "New Business Triggers uninstalled"
> 31         End If
> 32     End If
> 33     .ControlsAccepted = 2
> 34     .StartService
> 35 End With

> 37 If strLogText <> "" Then
> 38     ' Log to NB journal
> 39     JournalQWrite _
>         METHOD_NAME, _
>         "Status", _
>         strLogText

> 44     ' Log tot NT event viewer
> 45     Me.srvNTService.LogEvent _
>         svcMessageInfo, _
>         svcEventInformation, _
>         strLogText
> 49 End If
> 50 Me.Hide

> 52 Exit Sub
> 53 ErrorTrap:
> 54     ReportError METHOD_NAME

> End Sub

> 'end ******************
> Thanks in advance

> Dan



Mon, 09 Aug 2004 21:51:20 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Outlook won't start from VB NT Service

2. Windows NT, services, API's and VB

3. Created and installed VB.Net service but don't see it in services

4. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

5. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

6. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

7. Help with 'levels' of VB Controls

8. Help: W2K, IIS, ASP, Component Services, SQL, NT Service and VB

9. Writing NT's service program

10. querying a NT service's status

11. Here's a free NT Service OCX w/ source code

12. .EXE running from AT service on NT won't run with ORACLE ODBC

 

 
Powered by phpBB® Forum Software