|
-
Jun 3rd, 2004, 08:07 AM
#1
Thread Starter
New Member
Terminating vb.net prog in ms-dos batch file
I have a program created under the Empty Project option it builds, runs and actually works. When I run in batch file
i.e start /w prog.exe
it runs then doesn't terminate. In the task manager it is still running even when closed in windows.
Is the following the right way to end the program or should I place another qualifier on the start command line?
++++++++++++++++++++++++++++++++++++++++++++
srInput.Close()
fsInput.Close()
End
End Sub
-
Jun 3rd, 2004, 08:16 AM
#2
Are you trying to run the program through the VS IDE rather than stand-alone? If you are then the reason that it doesn't terminate, is that it halts just after the last command so yuo can read any error messages or whatever that came up in the console. (I'm assuming it is a console app?)
Run it standalone and you probably won't have this problem, I think
I don't live here any more.
-
Jun 3rd, 2004, 08:20 AM
#3
PS, lose the single End statement, it doesn't help matters.
I don't live here any more.
-
Jun 3rd, 2004, 09:16 AM
#4
Thread Starter
New Member
I've tried it without the last end statement. The program works standalone, but I must run it in a batch file, the last end statement gotten rid of made no difference.
Again it must be running in a ms-dos batch file since it runs at regular intervals throughout the day.
-
Jun 4th, 2004, 08:03 AM
#5
Can you show us your code for both the program and the batch file?
I have tried to re-create the situation on my PC but the batch file launches the prog and then quits it normally.
Last edited by wossname; Jun 4th, 2004 at 08:13 AM.
I don't live here any more.
-
Jun 4th, 2004, 08:14 AM
#6
The alternative being that you make it into a windows service instead and then it can run quite happilly for ever, only doing some processing at set intervals.
I don't live here any more.
-
Jun 4th, 2004, 09:18 AM
#7
Thread Starter
New Member
Here's the code....
Here is the program for project mickeymouse
simple program really, just opens and reads
the file is is this line:
szSrcLine = srInput.ReadLine()
which creates the hanging when the batch file
runs, the c:\daily_anyfile.txt is an ordinary text file
with a line of text in it.
I'm running under windows 2000
the batch file contains:
start /w c:\mickeymouse
the vb.net program is as follows:
' Import namespaces
Imports System
Imports System.Collections
Imports System.IO
Module Module1
Sub Main()
' Main variable declarations
' --------------------------
Dim strrecip As String
Dim strattach As String
Dim filedate
Dim currdate
Dim currline As Integer
Dim strline As String
Dim cnt As Integer
Dim attachment As String
Dim recipients As String
Dim linein As String
Dim szSrcFile As String
Dim szDestFile As String
Dim szFilemsg As String
Dim no_update As Integer
Dim all_details() As String
Dim Todays_date As Date
currdate = Format(Date.Today, "DD/MM/YYYY")
szSrcFile = "c:\daily_anyfile.txt"
' Read contents of the source file
Dim szSrcLine As String
Dim szContents As ArrayList
Dim fsInput As FileStream
Dim srInput As StreamReader
szContents = New ArrayList
fsInput = New FileStream(szSrcFile, FileMode.Open, FileAccess.Read)
srInput = New StreamReader(fsInput)
szSrcLine = srInput.ReadLine()
While Not IsNothing(szSrcLine)
If (Left(szSrcLine, 1) <> "!" And Left(szSrcLine, 1) <> "") Then 'Ignores line if it is commented out
'Here read the daily_cyberview.txt file and strip out the
'extraneous characters...
currline = currline + 1
all_details = Split(szSrcLine, ",")
attachment = all_details(0)
recipients = all_details(1)
'gets a time stamp of file
filedate = Format(FileDateTime(attachment), "DD/MM/YYYY")
'Checks to see if file has been updated
If filedate = currdate Then
' Call send_file(recipients, attachment)
cnt = cnt + 1
Else
no_update = no_update + 1
End If
' Read the next line from the input file
szSrcLine = srInput.ReadLine()
Else
End If
End While
' Close the input daily_cyberview.txt file
fsInput.Flush()
srInput.Close()
fsInput.Close()
End Sub
End Module
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|