[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

window Service

Asked by daruffin in Sharp Zaurus Operating System, .NET, Microsoft Visual Basic.Net

I need to execute a window on a timer which run a bat file. This bat file execute a vb.net program, which move data from a Mas database into a SQL Server Database. Each I run the bat file run but I don't get any line on my text file to explan that data has been moved

If I click on the bat file then it will run the process ut if I place it in a window service then it will run bu my text file does not tell what tables have been moved. Please review my code and let know why this window service will not run long enought to move data.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Configuration
Imports System.Data
Imports System.Web.Services
Imports System.Diagnostics
Imports System.ServiceProcess
Imports System.IO
Namespace mcWebService
    Public Class WinService1 : Inherits System.ServiceProcess.ServiceBase
        Private oTimer As System.Threading.Timer
        'Dim MyProcess As New Process
        Dim strTimeTxt As String
        Dim strFName As String
        Private components As System.ComponentModel.Container
        Public Sub New()
            ' This call is required by the WinForms Component Designer.
            InitializeComponent()
 
            ' TODO: Add any initialization after the InitComponent call
        End Sub
 
        ' The main entry point for the process
        Shared Sub Main()
            Dim ServicesToRun As System.ServiceProcess.ServiceBase()
            '   ServicesToRun = New System.ServiceProcess.ServiceBase[] {new WinService1(), new MySecondUserService()};
            '
            ServicesToRun = New System.ServiceProcess.ServiceBase() {New WinService1()}
 
            System.ServiceProcess.ServiceBase.Run(ServicesToRun)
        End Sub
        Private Sub InitializeComponent()
            Me.components = New System.ComponentModel.Container()
            '@this.TrayAutoArrange = true;
            '@this.TrayLargeIcon = false;
            Me.ServiceName = "mcWinService"
        End Sub
        Protected Overrides Sub OnStart(ByVal args() As String)
            ' Add code here to start your service. This method should set things
            ' in motion so your service can do its work.
            
            Dim oCallback As New Threading.TimerCallback(AddressOf OnTimedEvent)
            oTimer = New System.Threading.Timer(oCallback, Nothing, 60000, 60000)
 
           
            
        End Sub
        Protected Overrides Sub OnStop()
            ' Add code here to perform any tear-down necessary to stop your service.
            Dim objStreamWriter As System.IO.StreamWriter
            Dim strFName As String
            Dim dt2 As DateTime = DateTime.Now
            strFName = "C:\VBScan\Log\mcWindowsService.txt"
 
            If File.Exists(strFName) Then
                Dim FILENAME As String = strFName
                objStreamWriter = File.AppendText(FILENAME)
                objStreamWriter.BaseStream.Seek(0, SeekOrigin.End)
                objStreamWriter.WriteLine("VB_WinService: Service Started " & dt2)
                objStreamWriter.Flush()
                objStreamWriter.Close()
            Else
                objStreamWriter = File.CreateText(strFName)
                objStreamWriter.BaseStream.Seek(0, SeekOrigin.End)
                objStreamWriter.WriteLine("VB_WinService: Service Started " & dt2)
                objStreamWriter.Flush()
                objStreamWriter.Close()
            End If
 
 
        End Sub
        Private Sub OnTimedEvent(ByVal state As Object)
 
            Dim objStreamWriter As System.IO.StreamWriter
            Dim dt1 As DateTime = DateTime.Now
 
            strFName = "C:\VBScan\Log\VBSync.txt"
 
 
            Dim p As New Process
            Dim pi As New ProcessStartInfo("C:\Program Files\VBCC_Wireless\VBCC_WirelessInstaller\VBWS_Install.bat")
            p.StartInfo = pi
            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            p.Start()
            p.WaitForExit()
            p.Close()
 
 
            If File.Exists(strFName) Then
                Dim FILENAME As String = strFName
                objStreamWriter = File.AppendText(FILENAME)
                objStreamWriter.BaseStream.Seek(0, SeekOrigin.End)
                objStreamWriter.WriteLine("VB_WinService: Service Started " & dt1)
                objStreamWriter.Flush()
                objStreamWriter.Close()
            Else
                objStreamWriter = File.CreateText(strFName)
                objStreamWriter.BaseStream.Seek(0, SeekOrigin.End)
                objStreamWriter.WriteLine("VB_WinService: Service Started " & dt1)
                objStreamWriter.Flush()
                objStreamWriter.Close()
            End If
 
 
            Dim myLog As New EventLog
            If Not Diagnostics.EventLog.SourceExists("VBWatcher") Then
                Diagnostics.EventLog.CreateEventSource("VBWatcher", "VBWatcher Log")
            End If
            myLog.Source = "VBWatcher"
            myLog.WriteEntry("Something Happened!", EventLogEntryType.Information)
 
        End Sub
    End Class
End Namespace
 
 
'bat file
 
"C:\Program Files\VBCC_Wireless\VBCC_WirelessInstaller\Window_DataAutomation.exe"
[+][-]01/22/09 05:07 AM, ID: 23438926Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Sharp Zaurus Operating System, .NET, Microsoft Visual Basic.Net
Sign Up Now!
Solution Provided By: sirbounty
Participating Experts: 1
Solution Grade: B
 
[+][-]01/22/09 07:25 AM, ID: 23440073Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625