Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  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 log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
VMware and the Future of Virtualization

What's next for virtualization and business IT? Windows IT Pro senior editor Jeff James speaks with VMware President and CEO Diane Greene on the future of virtualization technology. ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

WinInfo Short Takes: Week of September 8, 2008

An often irreverent look at some of the week's other news, including the long-awaited back to school season, Microsoft's first Seinfeld/Gates ad, some EU insights, another Netbook improvement, Opera silliness, and much, much more ...


Related Articles More About Srvany

Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events 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 Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

IT Connections
Dive into the new Microsoft platforms and products you implement and support with the experts from Microsoft, TechNet Magazine, Windows ITPro and industry gurus. There are 70+ sessions and interactive panels with networking opportunities.

Attention User Group Leaders...
Announcing the eNews Generator—a FREE HTML e-newsletter builder for user group leaders. Build your HTML and text e-newsletters in minutes and add Windows IT Pro & SQL Server Mag articles alongside your own message!.

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Get SQL Server 2008 at WinConnections
Don’t miss Microsoft Exchange and Windows Connections conferences, the premier events for Microsoft IT Professionals in Las Vegas, November 10-13. Every attendee will receive a copy of SQL Server 2008 Standard Edition with one CAL.



Interested in Email Encryption?
Read about the advantages of identity-based encryption in this free report.

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16.
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 Windows Dev Pro IT Job Hound ITTV
IT Library Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing