VB pressed into Windows NT's service

Hello, Doctor!

How can I take a normal VB .exe file (for example, project1.exe) and turn it into a service so that the system will load it every time it starts, and not when I enter my own account (even when I have admin privilege...)?

Erez Chocva

Dr. GUI replies:

This is more like it. No decorating. (If you've ever seen Dr. GUI's office, you'd never ask him for decorating advice, anyway.) No mail or postal question. Good.

A service process under Windows NT has a special program architecture and is different from a regular Win32 application (such as Notepad.exe) in several ways. The Microsoft Platform SDK (formerly called the Win32 SDK) documents in detail how one can write a Windows NT service.

What this means is that one cannot take an existing regular Win32 program and run it as a Windows NT service without some effort. The application needs to be recoded so that it conforms to the Windows NT service architecture. And as far as the good doctor knows, that's not possible for Visual Basic applications.

One can, however, spawn a Win32 regular application from a Windows NT service. This allows you to have some of the benefits of a Windows NT service, such as the ability to run a process under a specified user account, the ability to run a process even when no one is logged on the machine, and so on.

The Windows NT version 4.0 resource kit provides a tool called SrvAny.exe for this purpose. This tool is actually a simple Windows NT service, which when started, spawns any regular Win32 application specified in its startup parameters. Please see SrvAny.wri in the Windows NT 4.0 resource kit for documentation of this tool.

Please note that spawning a process from a service is different from converting the process itself into a service. The latter may be the preferable option under certain circumstances (for example, if the process in question is an OLE server).