Hallo!
Hab da mal eine Frage/Problem:
Ich habe einen Dienst in vb6 gebaut der eine weitere Applikation starten soll.
Testweise habe ich mal versucht, Notepad über den Dienst zu starten, leider mit wenig Erfolg. (Dienst startet erfolgreich, Notepad erscheint aber nirgends. Wenn ich die selbe Shell aus einer App. heraus aufrufe, dann gehts.) Hier mal der Source:
Option Explicit
Dim strDisplayName As String
Dim TaskID As Long
Private Sub Form_Load()
On Error GoTo Err_Load
strDisplayName = NTService1.DisplayName
' Befehle zur Interaktion mit dem Desktop
If Command = "-install" Then
'Installieren
NTService1.Interactive = True
NTService1.StartMode = svcStartAutomatic
If NTService1.Install Then
MsgBox strDisplayName & " erfolgreich als Dienst installiert!", _
vbInformation
Else
MsgBox strDisplayName & " - Dienst konnte nicht installiert" & _
"werden!", vbCritical
End If
End
ElseIf Command = "-uninstall" Then
'Deinstallieren
If NTService1.Uninstall Then
MsgBox strDisplayName & " - Dienst erfolgreich deinstalliert!", _
vbInformation
Else
MsgBox strDisplayName & " - Dienst konnte nicht deinstalliert" & _
"werden!", vbCritical
End If
End
ElseIf Command = "-debug" Then
NTService1.Debug = True
End If
NTService1.ControlsAccepted = svcCtrlPauseContinue Or svcCtrlShutdown
NTService1.StartService
App.TaskVisible = False
DoEvents
Exit Sub
Err_Load:
If funCheckServiceWMI(NTService1.ServiceName) Then
Call NTService1.LogEvent(EventTypeOK, EventIDOK, "in err_load")
If NTService1.Interactive Then
MsgBox "[" & Err.Number & "] " & Err.Description
End
Else
Call NTService1.LogEvent(EventTypeError, EventIDError, "[" _
& Err.Number & "] " & Err.Description)
End If
Else
MsgBox Err.Description, vbCritical
End
End If
End Sub
Private Sub NTService1_Continue(Success As Boolean)
On Error GoTo Err_Continue
Err_Continue:
Call NTService1.LogEvent(EventTypeError, EventIDError, "[" & _
Err.Number & "] " & Err.Description)
End Sub
Private Sub NTService1_Pause(Success As Boolean)
On Error GoTo Err_Pause
Err_Pause:
Call NTService1.LogEvent(EventTypeError, EventIDError, "[" & _
Err.Number & "] " & Err.Description)
End Sub
Private Sub NTService1_Start(Success As Boolean)
On Error GoTo Err_Start
tmrRunner.Enabled = True
Success = True
Exit Sub
Err_Start:
Call NTService1.LogEvent(EventTypeError, EventIDError, "[" & _
Err.Number & "] " & Err.Description)
End Sub
Private Sub NTService1_Stop()
On Error GoTo Err_Stop
funAppExit
Exit Sub
Err_Stop:
Call NTService1.LogEvent(EventTypeError, EventIDError, "[" & _
Err.Number & "] " & Err.Description)
End Sub
Private Sub tmrRunner_Timer()
On Error GoTo Err_Timer
TaskID = Shell("c:\windows\system32\notepad.exe", vbNormalNoFocus)
' NotePad aktivieren
AppActivate TaskID
DoEvents
Err_Timer:
Call NTService1.LogEvent(EventTypeError, EventIDError, "[" & _
Err.Number & "] " & Err.Description)
End Sub Danke gleich mal für Antworten/Tipps |