473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Running A VB.NET Application as a Windows Service

DM
Hi All,

I have written a server program which distributes real-time data to our
customers and is also used by our customers to redistribute this data over
their internal networks. The program is just a standard Windows application
which minimizes to the systray and runs in the background.

Recently I have been asked by one of our clients whether I can make this
program run as a Windows service. After some Googling, it looks like it is
possible but it seems it would involve a major rewrite of the code.

Is there an easy way to do this?

-Duncan
Feb 27 '08 #1
6 4730
DM wrote:
Hi All,

I have written a server program which distributes real-time data to
our customers and is also used by our customers to redistribute this
data over their internal networks. The program is just a standard
Windows application which minimizes to the systray and runs in the
background.
Recently I have been asked by one of our clients whether I can make
this program run as a Windows service. After some Googling, it looks
like it is possible but it seems it would involve a major rewrite of
the code.
I don't see why it should be a major re-write. There is a template for building
a windows service in VS, start with that, and add your code into it. It doesn't
sound like you have much of a GUI anyway, so it shouldn't be that big a problem.
The simplest way to drive code in a service is with a timer, and you can do most
anything in the event handler. The only real trick is to build it in a robust
way, so it can reset itself if something goes wrong, and gives up and shuts down
if something stays wrong. It also helps if it logs events or notifications
somewhere so you can check up on it.
Feb 27 '08 #2
DM
"Steve Gerrard" <my********@comcast.netwrote in message
news:J-******************************@comcast.com...
DM wrote:
>Hi All,

I have written a server program which distributes real-time data to
our customers and is also used by our customers to redistribute this
data over their internal networks. The program is just a standard
Windows application which minimizes to the systray and runs in the
background.
Recently I have been asked by one of our clients whether I can make
this program run as a Windows service. After some Googling, it looks
like it is possible but it seems it would involve a major rewrite of
the code.

I don't see why it should be a major re-write. There is a template for
building a windows service in VS, start with that, and add your code into
it. It doesn't sound like you have much of a GUI anyway, so it shouldn't
be that big a problem. The simplest way to drive code in a service is with
a timer, and you can do most anything in the event handler. The only real
trick is to build it in a robust way, so it can reset itself if something
goes wrong, and gives up and shuts down if something stays wrong. It also
helps if it logs events or notifications somewhere so you can check up on
it.
I should have mentioned that I only have Visual Basic .NET 2003 standard so
no Windows service template unfortunately.

The program does have a reasonably complex GUI which allows the user to
manage client details, log network activity, set up audio & email service
alerts, track data rates etc so I'm not sure whether it's going to be that
easy.

I believe our client's problem is that they are running this application
under Windows Server 2003 and when they log on via Remote Desktop to check
the program status, then log out, it shuts the server down. Perhaps there is
another way of getting around this in the code rather than making it a
Windows service?

-Duncan
Feb 27 '08 #3
DM wrote:
>>

I should have mentioned that I only have Visual Basic .NET 2003
standard so no Windows service template unfortunately.
I have VS 2003 at home, and it has a VB WindowsService project type, but I'm not
sure which edition it is.
>
The program does have a reasonably complex GUI which allows the user
to manage client details, log network activity, set up audio & email
service alerts, track data rates etc so I'm not sure whether it's
going to be that easy.
Since a service does not have a GUI, that could be a problem. :)
>
I believe our client's problem is that they are running this
application under Windows Server 2003 and when they log on via Remote
Desktop to check the program status, then log out, it shuts the
server down. Perhaps there is another way of getting around this in
the code rather than making it a Windows service?
I would try running the app from the Run key in the registry
(HLM\Software\Microsoft\Windows\CurrentVersion\Run ). I'm not sure if that is all
it takes, but you don't want the app to run under a particular user logon, else
it will shut down when that user logs off.

Feb 27 '08 #4
On Feb 27, 3:23 am, "DM" <nos...@nospam.orgwrote:
Hi All,

I have written a server program which distributes real-time data to our
customers and is also used by our customers to redistribute this data over
their internal networks. The program is just a standard Windows application
which minimizes to the systray and runs in the background.

Recently I have been asked by one of our clients whether I can make this
program run as a Windows service. After some Googling, it looks like it is
possible but it seems it would involve a major rewrite of the code.

Is there an easy way to do this?

-Duncan
Hi,
You can modify / add / delete any correct service in that registry
entry:
[HKEY_LOCAL_MACHINE \System \CurrentControlSet \Services]

See some existing service registry tree structure to do the same for
yours.
Feb 27 '08 #5
Hi,

It isn't usual/common to have a Service with a UI. However, it is possible.

I have a VB.NET 2005 example on my homepage, with an article that outlines
some of the steps, and that has links to other information. IMO, 2005 or
2008 would be a useful upgrade for your program.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Feb 27 '08 #6
DM
"Steve Gerrard" <my********@comcast.netwrote in message
news:os******************************@comcast.com. ..
DM wrote:
....
>>
I believe our client's problem is that they are running this
application under Windows Server 2003 and when they log on via Remote
Desktop to check the program status, then log out, it shuts the
server down. Perhaps there is another way of getting around this in
the code rather than making it a Windows service?

I would try running the app from the Run key in the registry
(HLM\Software\Microsoft\Windows\CurrentVersion\Run ). I'm not sure if that
is all it takes, but you don't want the app to run under a particular user
logon, else it will shut down when that user logs off.
Thanks I'll give this a go.

-Duncan
Feb 28 '08 #7

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

Similar topics

0
by: Marian Dvorsky | last post by:
I would like to create an application that will be running in the background and will have an icon in the Notify bar in the lower-right corner of Windows desktop. For Windows NT+ I will probably...
13
by: BK | last post by:
Can someone point me to a code sample that illustrates executing long running tasks (asynchronous) from a web application in ASP.NET? I assume that Web Services might come into play at some point,...
0
by: Martijn Remmen | last post by:
I have developed a service which exposes a COM object. This service is running perfect on Windows 2000 Server and Windows 2000 Professional under the SYSTEM account. When the service is...
0
by: Mr Bounce | last post by:
Hi, Probably well worn ground, this, but im stumped and need some help, if you could: I'm trying to write some code for a windows service that needs to run in the background polling a server...
1
by: Peter Rilling | last post by:
I have an EXE that I would like to be able to run from either the command-line or as a windows service. Is there a way that I can tell which context the program is running in? Basically, if it...
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
5
by: =?Utf-8?B?cnZhbmdlbGRyb3A=?= | last post by:
Hello, I have a problem with our OnlineBackupService.exe. This is a Windows Service which is built in .Net 1.1 and basically grabs files from the file system and will try to upload them using...
2
by: tom.sikes | last post by:
We wrote some code (utility stuff) that is intended to run as part of either a windows service, a console app or a windows app. What I'd like to do is when it is running as a service have it log...
3
by: Cor Pruim | last post by:
I have a very strange problem. I have written a Windows Service with VS2003 in vb.net. This service does some calculations and after that it needs to produce some Excel reports by getting data from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.