G
Guest
I hope this is a right place to post my question
I'm working on a Windows service application with VB.net. The purpose is to let the service application as a monitor to periodically check a launching flag file. If the flag was found the service will trigger to run a finance calculating program (VMPE4SRVAPP.exe, a VB 6.0/Access application but without windows interface). I added a Process and two Timers on the Service to do checking and launching jobs (Process1.Start to call VMPE4SRVAPP.exe) . Please see the following code
Imports System.ServiceProces
Public Class MyNewServic
Inherits System.ServiceProcess.ServiceBas
Protected Overrides Sub OnStart(ByVal args() As String
EventLog1.WriteEntry("In OnStart"
Timer2.Enabled = Tru
End Su
Protected Overrides Sub OnStop(
EventLog1.WriteEntry("In OnStop."
End Su
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapse
Timer1.Enabled = Fals
Dim myProcess As New Proces
Process1.StartInfo.FileName = "C:\VMPE4SRVAPP\VMPE4SRVAPP.exe
Process1.StartInfo.Arguments = "vm3retail
Process1.StartInfo.WorkingDirectory = "C:\VMPE4SRVAPP
Process1.StartInfo.RedirectStandardOutput = Fals
Process1.StartInfo.WindowStyle = ProcessWindowStyle.Minimize
Process1.Start(
Timer2.Enabled = Tru
End Su
Private Sub Timer2_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer2.Elapse
If Len(Dir("C:\temp\LaunchingFlag.ok")) > 0 The
Timer2.Enabled = Fals
Kill("C:\temp\LauchingFlag.ok"
Timer1.Enabled = Tru
End I
End Su
End Clas
I installed the service. When I started it, I could see (from windows explorer) a MDB file was generated and its size indicated that data was loaded. I also saw VMPE4SRVAPP.exe was displayed on Processes tab of Windows Task Manager. However the process stayed on the tab forever. When I tried to open the MDB file, I got "Access denied... It is already being in use". When I tried to copy the MDB I got "Sharing violation".
I can only access the MDDB file after I re-boot my PC
What's wrong with my code? Or is there a better way to call my VB 6.0 Calc application in Windows Service? Can I use Shell in a Service instead of Process (If I can how to coding them)
Thanks for your help
I'm working on a Windows service application with VB.net. The purpose is to let the service application as a monitor to periodically check a launching flag file. If the flag was found the service will trigger to run a finance calculating program (VMPE4SRVAPP.exe, a VB 6.0/Access application but without windows interface). I added a Process and two Timers on the Service to do checking and launching jobs (Process1.Start to call VMPE4SRVAPP.exe) . Please see the following code
Imports System.ServiceProces
Public Class MyNewServic
Inherits System.ServiceProcess.ServiceBas
Protected Overrides Sub OnStart(ByVal args() As String
EventLog1.WriteEntry("In OnStart"
Timer2.Enabled = Tru
End Su
Protected Overrides Sub OnStop(
EventLog1.WriteEntry("In OnStop."
End Su
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapse
Timer1.Enabled = Fals
Dim myProcess As New Proces
Process1.StartInfo.FileName = "C:\VMPE4SRVAPP\VMPE4SRVAPP.exe
Process1.StartInfo.Arguments = "vm3retail
Process1.StartInfo.WorkingDirectory = "C:\VMPE4SRVAPP
Process1.StartInfo.RedirectStandardOutput = Fals
Process1.StartInfo.WindowStyle = ProcessWindowStyle.Minimize
Process1.Start(
Timer2.Enabled = Tru
End Su
Private Sub Timer2_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer2.Elapse
If Len(Dir("C:\temp\LaunchingFlag.ok")) > 0 The
Timer2.Enabled = Fals
Kill("C:\temp\LauchingFlag.ok"
Timer1.Enabled = Tru
End I
End Su
End Clas
I installed the service. When I started it, I could see (from windows explorer) a MDB file was generated and its size indicated that data was loaded. I also saw VMPE4SRVAPP.exe was displayed on Processes tab of Windows Task Manager. However the process stayed on the tab forever. When I tried to open the MDB file, I got "Access denied... It is already being in use". When I tried to copy the MDB I got "Sharing violation".
I can only access the MDDB file after I re-boot my PC
What's wrong with my code? Or is there a better way to call my VB 6.0 Calc application in Windows Service? Can I use Shell in a Service instead of Process (If I can how to coding them)
Thanks for your help