473,659 Members | 3,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net Console app needs timer

Hi,

I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.

The app coding so far is this;

'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott

Jul 5 '07 #1
15 6713
On Jul 5, 1:30 pm, "Scott M." <quan...@gmail. comwrote:
Hi,

I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.

The app coding so far is this;

'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)

Scott
This may not be the "proper" way - but I never cared about being
proper. :-)

I would first add a reference to System.Windows. Forms to my project
and do this:

Imports System.Windows. Forms

Module Module1

Sub Main()
Dim t As New Timer
t.Interval = 600000 '// I think 10 minutes = 600,000
milliseconds :-)
AddHandler t.Tick, AddressOf timer_Tick
t.Start()

Application.Run ()
End Sub

Public Sub timer_Tick(ByVa l sender As Object, ByVal e As
EventArgs)
Using writer As New System.IO.Strea mWriter("C:\Tes t.txt")
writer.WriteLin e("Heartbeat File")
writer.WriteLin e(DateTime.Now)
End Using
End Sub

End Module

Thanks,

Seth Rowe

Jul 5 '07 #2
On Jul 5, 1:40 pm, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On Jul 5, 1:30 pm, "Scott M." <quan...@gmail. comwrote:
Hi,
I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.
The app coding so far is this;
'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott

This may not be the "proper" way - but I never cared about being
proper. :-)

I would first add a reference to System.Windows. Forms to my project
and do this:

Imports System.Windows. Forms

Module Module1

Sub Main()
Dim t As New Timer
t.Interval = 600000 '// I think 10 minutes = 600,000
milliseconds :-)
AddHandler t.Tick, AddressOf timer_Tick
t.Start()

Application.Run ()
End Sub

Public Sub timer_Tick(ByVa l sender As Object, ByVal e As
EventArgs)
Using writer As New System.IO.Strea mWriter("C:\Tes t.txt")
writer.WriteLin e("Heartbeat File")
writer.WriteLin e(DateTime.Now)
End Using
End Sub

End Module

Thanks,

Seth Rowe
I forgot to add - using the System.Windows. Forms timer in a console
project is considered a no-no by some - you can use the other
available timers if you want, but I prefer the simplicity of the Forms
timer.

Thanks,

Seth Rowe

Jul 5 '07 #3
Why not use the scheduler?

--
cheers,
RL
"Scott M." <qu*****@gmail. comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.com.. .
Hi,

I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.

The app coding so far is this;

'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott

Jul 5 '07 #4
On Jul 5, 2:41 pm, "Egghead" <robertlo@NO_SH AW.CAwrote:
Why not use the scheduler?

--
cheers,
RL"Scott M." <quan...@gmail. comwrote in message

news:11******** **************@ m36g2000hse.goo glegroups.com.. .
Hi,
I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.
The app coding so far is this;
'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott- Hide quoted text -

- Show quoted text -
I am too new to VB2005 to know how to use it. Can you give me a hint?

Jul 5 '07 #5

"Scott M." <qu*****@gmail. comwrote in message
news:11******** *************@q 75g2000hsh.goog legroups.com...
On Jul 5, 2:41 pm, "Egghead" <robertlo@NO_SH AW.CAwrote:
>Why not use the scheduler?

--
cheers,
RL"Scott M." <quan...@gmail. comwrote in message

news:11******* *************** @m36g2000hse.go oglegroups.com. ..
Hi,
I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.
The app coding so far is this;
'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott- Hide quoted text -

- Show quoted text -

I am too new to VB2005 to know how to use it. Can you give me a hint?
Start Menu Settings Control Panel Scheduled Tasks Add Task...

Al G
Jul 5 '07 #6
On Jul 5, 3:08 pm, "Al G" <agerha...@char ter.netwrote:
"Scott M." <quan...@gmail. comwrote in message

news:11******** *************@q 75g2000hsh.goog legroups.com...


On Jul 5, 2:41 pm, "Egghead" <robertlo@NO_SH AW.CAwrote:
Why not use the scheduler?
--
cheers,
RL"Scott M." <quan...@gmail. comwrote in message
>news:11******* *************** @m36g2000hse.go oglegroups.com. ..
Hi,
I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.
The app coding so far is this;
'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott- Hide quoted text -
- Show quoted text -
I am too new to VB2005 to know how to use it. Can you give me a hint?

Start Menu Settings Control Panel Scheduled Tasks Add Task...

Al G- Hide quoted text -

- Show quoted text -
Oh, that scheduler. I can use it to launch my tiny program, but I need
the program to write out my heartbeat file every ten minutes. I could
just as easily put my program in the startup folder.

Jul 5 '07 #7

"Scott M." <qu*****@gmail. comwrote in message
news:11******** **************@ i13g2000prf.goo glegroups.com.. .
On Jul 5, 3:08 pm, "Al G" <agerha...@char ter.netwrote:
>"Scott M." <quan...@gmail. comwrote in message

news:11******* **************@ q75g2000hsh.goo glegroups.com.. .


On Jul 5, 2:41 pm, "Egghead" <robertlo@NO_SH AW.CAwrote:
Why not use the scheduler?
>--
cheers,
RL"Scott M." <quan...@gmail. comwrote in message
>>news:11****** *************** *@m36g2000hse.g ooglegroups.com ...
Hi,
I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want
to
do is be able to examine my DriveHQ account and see, from what I
write
in the text file, that my systems are up and running.
The app coding so far is this;
'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott- Hide quoted text -
>- Show quoted text -
I am too new to VB2005 to know how to use it. Can you give me a hint?

Start Menu Settings Control Panel Scheduled Tasks Add Task...

Al G- Hide quoted text -

- Show quoted text -

Oh, that scheduler. I can use it to launch my tiny program, but I need
the program to write out my heartbeat file every ten minutes. I could
just as easily put my program in the startup folder.
What's wrong with using System.Timers name space to create a timer with an
AddressHandler for the time elasped. I done it in console applications.
>
Jul 5 '07 #8
On Jul 5, 2:52 pm, "Scott M." <quan...@gmail. comwrote:
On Jul 5, 3:08 pm, "Al G" <agerha...@char ter.netwrote:
"Scott M." <quan...@gmail. comwrote in message
news:11******** *************@q 75g2000hsh.goog legroups.com...
On Jul 5, 2:41 pm, "Egghead" <robertlo@NO_SH AW.CAwrote:
>Why not use the scheduler?
>--
>cheers,
>RL"Scott M." <quan...@gmail. comwrote in message
>>news:11****** *************** *@m36g2000hse.g ooglegroups.com ...
Hi,
I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.
The app coding so far is this;
'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott- Hide quoted text -
>- Show quoted text -
I am too new to VB2005 to know how to use it. Can you give me a hint?
Start Menu Settings Control Panel Scheduled Tasks Add Task...
Al G- Hide quoted text -
- Show quoted text -

Oh, that scheduler. I can use it to launch my tiny program, but I need
the program to write out my heartbeat file every ten minutes. I could
just as easily put my program in the startup folder.
But that will only launch your program once. Set the scheduled task
to run your program every 10 minutes. That way, all you need to do in
your program is just create the file and you don't have to worry about
the timer.

Chris

Jul 6 '07 #9
On Jul 6, 9:27 am, Chris Dunaway <dunaw...@gmail .comwrote:
On Jul 5, 2:52 pm, "Scott M." <quan...@gmail. comwrote:


On Jul 5, 3:08 pm, "Al G" <agerha...@char ter.netwrote:
"Scott M." <quan...@gmail. comwrote in message
>news:11******* **************@ q75g2000hsh.goo glegroups.com.. .
On Jul 5, 2:41 pm, "Egghead" <robertlo@NO_SH AW.CAwrote:
Why not use the scheduler?
--
cheers,
RL"Scott M." <quan...@gmail. comwrote in message
>news:11******* *************** @m36g2000hse.go oglegroups.com. ..
Hi,
I'm an old VB6 guy just starting out in VB.Net using Visual Studio
Express. I want to build a simple console app that will create a
simple text file every 10 minutes. I can create the file OK, but how
do I put in the timer so that I can write the file on schedule? The
idea behind this project is to help me monitor remote computers in a
production environment to make sure that they are up and running. I
currently synchronize files on them using DriveHQ.com. What I want to
do is be able to examine my DriveHQ account and see, from what I write
in the text file, that my systems are up and running.
The app coding so far is this;
'create file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt",
String.Empty, False)
'write file header
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", "Heartbeat
File" & vbCrLf, True)
'write current date/time to file
My.Computer.Fil eSystem.WriteAl lText("C:\Test. txt", Now() &
vbCrLf, True)
Scott- Hide quoted text -
- Show quoted text -
I am too new to VB2005 to know how to use it. Can you give me a hint?
Start Menu Settings Control Panel Scheduled Tasks Add Task...
Al G- Hide quoted text -
- Show quoted text -
Oh, that scheduler. I can use it to launch my tiny program, but I need
the program to write out my heartbeat file every ten minutes. I could
just as easily put my program in the startup folder.

But that will only launch your program once. Set the scheduled task
to run your program every 10 minutes. That way, all you need to do in
your program is just create the file and you don't have to worry about
the timer.

Chris- Hide quoted text -

- Show quoted text -
I agree with you Chris, but I've looked at Scheduler and I don't think
I can launch a task any more than once per day. Try it by setting up
NotePad or some other app to run, just to see how often you can get it
to run.

Scott

Jul 6 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5377
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
11
24048
by: avivgur | last post by:
Hello, I have devised a console application that uses a System.Timers.Timer and its Elapsed event. The problem is that I want the program to continue to run so that each time the event is raised, the handler will be executed. I tried using a while(timer.Enabled) {} loop but it made the process use 90% cpu in the task manager. What is the correct way to wait for an event and keep the program alive in a console application? Thanks, Aviv.
4
8095
by: VB Programmer | last post by:
I'm creating a console application. Can I use a timer control to do something every 5 seconds?
1
920
by: Dan | last post by:
I have been struggling with a console app that I have written. Perhaps there are some gurus out there that can clear up a few things for me. My history is with VB where you have a form and a butt on and so on. When you click, load, change a control you can run some code with that event. I am hoping that I can translate that sort of functionality to a console app and eventually a service. I want to have, say, a timer control in my console...
8
18638
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window available in the same form for users to enter commands and display outputs if some prefer to use character based user interface. I would like to implement the user interface in vb .net. Now I have menus and toolbars ready, but do not now how to get a...
13
3854
by: Mark A. Nadig | last post by:
I've got a console application in vb.net to replicate the behavior of the old DOS command CHOICE. I've got a timer event successfully firing, however the main thread is stuck on the console.read(). How can I interrupt that and have it return the default errorlevel? Any suggestions? I appreciate your thoughts. On another note: If someone knows how to easily read a single key from the console instead of relying on the user to hit enter,...
6
19761
by: Aart Nicolai | last post by:
Hi all, I have developed a vb.net console application which will run some code every seconds. To get this working I used a timer "System.Timers". When I start my console application it exits within a second. So I added the line: "Console.Read()". Everything seemes to run fine but after a few days the application stopped. Without an error. I think it has something to do with the lifetime of the "Console.Read()". Is this right?
2
3533
by: Svein Erik | last post by:
Is it possible to use a ticker in a console-application? How can I do this?
3
1380
by: =?Utf-8?B?VGVycmFuY2U=?= | last post by:
Good Afternoon: I have two questions I was hoping someone can help me with. 1. I've created a app that creates a xml file; the project was constructed as a console window. I want to know is there anyway to suppress the console window from showing? One of the options is I have is to generate the xml file without showing the console window. Even though I'm not calling the Console it still flashes. Any suggestions. I plan on running this...
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.