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. ...

A Great Tool For Making Screencasts

I've started making product demos and have found a tool that has helped make the job easier--Camtasia. ...


Related Articles More About Srvany

Windows OSs Whitepapers Replay for Exchange: Enterprise Protection and an Affordable Price

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 Disaster Recovery and Backup

A Guide to Windows Certification and Public Keys

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.


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Critical Challenges of ESI & Email Retention
Are you storing too much electronic information? Get expert legal advice and better understanding of what you are required to do as an IT professional.

Become a fan of Windows IT Pro on Facebook!
Join us on Facebook and be a fan of Windows IT Pro!

Sustainable Compliance: Are You Having a Resource Crisis?
Read this white paper to examine trends in compliance and security management and review approaches to reducing the cost and operational burden of compliance.

Rev Up Your IT Know-How with Our Recharged Magazine!
The improved Windows IT Pro provides trusted IT content with an enhanced new look and functionality! Get comprehensive coverage of industry topics, expert advice, and real-world solutions—PLUS access to over 10,000 articles online. Order today!

Get It All with Windows IT Pro VIP
Stock your IT toolbox with every solution ever printed in Windows IT Pro and SQL Server Magazine plus bonus Web-exclusive content on hot topics. Subscribe to receive the VIP CD and a subscription to your choice of Windows IT Pro or SQL Server Magazine!



Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.
Windows IT Pro Home Register About Us Affiliates / Licensing Media Kit Contact Us/Customer Service  
SQL Connected Home IT Library SuperSite FAQ Wininfo News
Europe Edition Office & SharePoint Pro Windows Dev Pro Windows Excavator 
 
 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