Home Index

Run Windows application in background or as a service 
 
Date: Dec 01 2000
Subject: Online Programmer Ezine, Volume 1, No.2
Article: Run Windows application in background or as a service 

Sometimes we need an application to run every time we start 
windows, even when user has not logged in. It is something 
like service programs that run in background even if we do 
not see them. In this article we will tell you how to do 
this in windows 98 and 95. In next issue we will see how to
run an application as a service like other services in 
windows NT and 2000.

You must be familiar with windows registry before you can 
use this. You will need to add your program executable name 
and its path in windows registry.

Let's assume that our application executable is 'test.exe' 
and its path is 'c:\testapp'. 

1- If you want to run your program every time win98 starts 
(after login) you will need to add a String Value in the 
following key in registry :

HKEY_LOCAL_MACHINE
   \SOFTWARE\Microsoft\Windows\CurrentVersion\Run

Name: test
Type: String (REG_SZ)
Value: c:\testapp\test.exe

If you want your application to run for a specific user you 
must change root key to HKEY_CURRENT_USER. In this way your
application will run for the person who was in windows when 
creating this key. (usually the person who installs your 
software)


2- If you want to run your program every time win98 starts 
(before login) you will need to add a String Value in the 
following key in registry :

HKEY_LOCAL_MACHINE
     \SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices

Name: test
Type: String (REG_SZ)
Value: c:\testapp\test.exe


3- If you want to run a program only once when win98 starts 
you will need to add a String Value in the following key in
registry :

HKEY_LOCAL_MACHINE
      \SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

Name: test
Type: String (REG_SZ)
Value: c:\testapp\test.exe

After running the application for the first time windows 
will clear this application from RunOnce list.

To add this values to specified key you can use install 
maker programs such as "Install Shield" or you can write 
your own install program that adds these values to registry
when installing your application. 

In next issues of this ezine we will see how to install your
application as a Windows NT and 2000 service program that 
starts and stops as other service programs. We will also 
have articles about registry programming in VB, Delphi and 
C++ Builder.

If you have any problem or question about this article you
can ask it in our programming forums and I and other 
subscribers will answer your questions. Just visit our 
website and leave your message !



Home Index
© 2000 OnlineProgrammer (HtmSoft.com). All Rights Reserved