Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


February 2000

Srvany


RSS
Subscribe to Windows IT Pro | See More Products / Software Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Of all the capabilities that separate Windows NT from earlier Microsoft OSs, services are among my favorite. For example, if you run Web or mail server software as a service, you don't need to start up the Web or mail server software every time you reboot the system. Because the software runs as a service, it starts automatically. In addition, services run in the background without cluttering up your desktop or system tray, and they run when no one is logged on. Thus, your Web or mail server software will automatically restart after a power failure. Furthermore, services can run with more rights and permissions than the person operating the computer has.

However, for a program to run as a service, the developer must have built the program to do so. Many programs aren't designed to run automatically. For example, the nifty little Visual Basic (VB) program you whipped up to update content on your Web site every hour won't run unless someone is logged on to make the program work. Rebuilding a program to run as a service isn't difficult, but if you don't have a program's source code, you can't modify the application so that it can run as a service.

The Microsoft Windows NT Server 4.0 Resource Kit's srvany.exe tool offers a solution. Srvany lets you run just about any program as a service, without requiring you to rebuild the application as a service. Installing and using the tool is involved, so I'll use this column and my next column to discuss the process.

The idea behind Srvany is clever: Instead of rebuilding a program as a service, you run the Srvany service, and Srvany launches the program. Because Srvany won't launch all types of programs, you must experiment to determine whether the service will launch a particular program. In addition, some applications will work as services only while you're logged on. When you log off, NT sends a command to all running programs announcing that you're logging off. Many interactive programs, such as word processors and Web browsers, pay attention to the user is logging off command and respond by shutting themselves down. Such programs won't run successfully as services.

Preparing a program to run as a service involves several steps. First, use the resource kit's Instsrv tool to install Srvany as a service. Every service has a Registry key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services that describes the service. For example, the DHCP Server service's key name is DHCPServer. Srvany lets you choose a key name for its service. This factor is important because you need to install Srvany as a service once for each program that you want to make a service. Installing Srvany under several key names lets you create placeholders for many programs that Srvany can then launch.

Suppose you have a program named notify.exe that you want to make a service. You'd install Srvany and give the service a key name such as notify. To start Instsrv, you'd enter

instsrv notify <fullpathname>\srvany.exe

You need to include the entire path to the location of srvany.exe. I've been able to make Srvany work without specifying a path if I put the srvany.exe file in the \winnt directory, but including the full pathname is a good idea.

You probably also need to change Srvany's service account. When you run a program from the desktop, the program impersonates you and has your permissions and rights. In contrast, a service doesn't run with your permissions and rights. Instead, services run with the permissions and rights of the System account (aka the LocalSystem account). The System account has a lot of power over the workstation or server that the account is running on but virtually no power outside that machine (i.e., over the network). Thus, you might need to let the service that you're running impersonate you. Open the Control Panel Services applet, locate the service, and click Startup. In the Log On As dialog box that opens, select Browse, and select your account and password.

Setting up Srvany is fairly simple. In my next column, I'll use the notify.exe example to explain how to make Srvany run a program as a service.

End of Article



Reader Comments
just great

ravinder thakur November 19, 2003


This article is great. Clear and interesting.

Kendrick May 07, 2004


Awsome but, you said Rebuilding a program to run as a service isn't difficult, but if you don't have a program's source code, you can't modify the application so that it can run as a service. so... how do I do that? :) I have the source but no idea how to do that.

Dave June 08, 2004


NIce info.

Anonymous User March 01, 2005


I am able to run my application through this. I am making it interact with console. When I close that window or some error occurs in my program and it exits, I ant it to get started again by itself. Can u suggest ho can it be done

Anonymous User April 12, 2005 (Article Rating: )


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

Windows 7 Sets Sales Record

Microsoft CEO Steve Ballmer described Windows 7's first ten days of sales as "fantastic" while in Japan yesterday. ...


Related Articles More About Srvany

Related Events WinConnections and Microsoft® Exchange Connections

Deep Dive into Windows Server 2008 R2 presented by John Savill

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement