Curb Unneeded Services in Windows 7
revised 1 Jan 2011
Copyright © 2011–2012 by Stan Brown, Oak Road Systems
revised 1 Jan 2011
Copyright © 2011–2012 by Stan Brown, Oak Road Systems
The process is a nutshell: find and stop the relevant service(s), build a batch file to manage the services and the application in one go, and create an administrator shortcut in your start menu to that batch file. and set As always, the devil is in the details, but I’ll walk you through step by step.
Contents:
See also: Other Windows tips (all of them shorter!) are at Windows 7 Tips and Tweaks.
Why not just let the applications’ services run continuously in background? Well, any program has to add some time to your bootup and take some system resources. Only you can judge if it’s a big enough deal to be worth fighting back. My own preference is to have as little running as possible, because then I’m more likely to spot something running that shouldn’t be. Plus, I just like to keep things lean and clean.
Some history: This idea was suggested to me by an article on Lifehacker.com called Create Service-Stopping Batch Files to Optimize Your PC for Specific Tasks. But that’ article did just one piece of the job. Stopping services after the application runs wasn’t enough. This is a computer, and I want to click one thing to run my application. That means one automated process of starting the services, launching the application, and then stopping the services after the application finishes.
“Automated process” suggests a script or a batch file.
As it happens, I know the command line and batch files and I
don’t know Windows scripting, so the choice was easy for me.
I knew the nucleus would be a start /wait
command to launch the application. But things turned out to be
rather more complex than I expected. I have to say
a big thank-you to the folks in the newsgroup alt.windows7.general,
who generously helped
me get past several obstacles including some errors of my own.
The two applications that most concerned me, iTunes and Acronis TrueImage, turned out to be rather different in the way they handle services. Between the two of them, I think you’ll see all you need to tackle your favorite application. If you find some wrinkle that I’ve missed, please write and let me know.
Applies to: Acronis TrueImage Home 10 and 11. I suspect other Acronis versions have the same issues, but you should check for yourself if you’re following these instructions to tame Acronis services.
Like many people, I use an external hard drive for backups. And I connect it only when I’m actually doing a backup.Why “Nonstop Backup Service” must be running when I don’t do nonstop backups, and why “Acronis Scheduler2 Service” must be running when I don’t do scheduled backups (and when Windows has a perfectly good scheduler), Acronis was unable to tell me. Why these services must be running when making an on-demand backup, Acronis was also unable to tell me, but experiment shows that they have to be.
The plan: Set these two services to “Manual” so that they don’t start with Windows. Then, in a batch file called AcronisBackup.bat, start them before running Acronis and stop them after running Acronis.
You set service properties in the Services.msc program, which
will prompt you for administrative privilege when you run it. Click
the Windows start button, type services and press the
Enter key.
Find “Acronis Nonstop Backup Service”, right-click it
and select Properties. Select the General
tab of the dialog.Repeat those steps for “Acronis Scheduler2 Service”. Its service name is AcrSch2Svc. Then close the main Services window.
Decide where you’ll put your batch file. I don’t recommend anywhere in C:\Program Files or C:\Program Files (x86), because Windows 7 really likes to manage those by itself. I personally use C:\Utilities, but you could use any of your folders.
setlocal disableextensions @echo. @echo Have you emptied the Recycle Bin? @echo. @pause net start afcdpsrv net start AcrSch2Svc start "Acronis" /wait "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImage.exe" net stop afcdpsrv net stop AcrSch2Svc endlocal
Check your install path for Acronis, and make the appropriate change if it’s different from mine.
Curious about the batch commands? See Batch File Arcana, below.
Keep this window open, because it’s needed in the next section.
Finally, create a shortcut to this batch file and place the shortcut in the start menu. From then on, use this shortcut instead of the one that Acronis created.
And that’s it at last. Now I use my new shortcut instead of the Acronis-made shortcut. I get the administrator prompt and answer it, the services start almost instantly, and I’m in Acronis TrueImage. The batch file is still there, waiting for me to finish with Acronis, and when I do it stops the services and exits. No extra work for me, and I have two fewer services running all the time in background.
Applies to: iTunes 9 and 10. I have iTunes 9 and haven’t seen any compelling reason to upgrade. Ed Bott has written about the iTunes 10 installer, and it seems pretty similar, with one exception that I’ll get to.
Apple Mobile Device isn’t needed for my particular iPod. Bonjour is for file sharing across networks and for Apple TV, which I don’t have. iPod Service is needed to sync my iPod, but not when I just want to run iTunes to listen to music or manage media files.
Your equipment and usage may be different from mine, so you might need to disable fewer or different services. See Bott’s article for guidance based on your needs.
Apple Software Update is a question mark. Bott’s article makes it sound pretty obtrusive, but I’m not seeing it as a background process in Task Manager nor as a service in Services.msc, even though Control Panel → Programs and Features shows it as installed. Either this is a difference between iTunes 9 and 10, or I disabled it long ago and forgot about it.
Why disable the services, rather than just stop them as I did with Acronis? Because if the services are merely stopped, iTunes starts them again. (I’m not certain about Bonjour and Apple Mobile, but I have tested iPod Service and iTunes definitely restarts it.) So it’s necessary to disable them.
You set service properties in the Services.msc program, which
will prompt you for administrative privilege when you run it. Click
the Windows start button, type services and press the
Enter key.
Repeat those steps for “Bonjour Service”.
Repeat again for “iPod Service”. Since this one will have to be accessed in the batch file, take note of the service name. For this service it’s the same as the display name, iPod Service.
Decide where you’ll put your batch file. I don’t recommend anywhere in C:\Program Files or C:\Program Files (x86), because Windows 7 really likes to manage those by itself. I personally use C:\Utilities, but you could use any of your folders.
setlocal disableextensions sc config "iPod Service" start= demand net start "iPod Service" start "iTunes" /wait "C:\Program Files (x86)\iTunes\iTunes.exe" net stop "iPod Service" sc config "iPod Service" start= disabled endlocal
Check your install path for iTunes, and make the appropriate change if it’s different from mine.
Curious about the batch commands? See Batch File Arcana, below.
Keep this window open, because it’s needed in the next section.
Finally, create a shortcut to this batch file and place the shortcut in the start menu.
Finally! Now I have two paths for running iTunes:
For just managing or listening to media, I run the
shortcut that Apple installed. That gives the nag message shown at
right; I click No and iTunes runs fine. (I choose not to click
“Do not show this message again” because I actually like the
reminder that iTunes is running the “other way”. It’s
your choice.)Error message from Bonjour: The first time you run iTunes after making these changes, it will complain that Bonjour isn’t running and tell you about all the devices you can’t use without it. You can safely dismiss that message if you don’t have any of those devices.
As I said at the outset, I knew that the
nucleus would be a start /wait command, but things
quickly got more complicated. Here’s what I learned on my own
and
with the help of the good folks in the alt.windows7.general newsgroup.
/wait Work The /wait option is needed on
program launch to pause the batch file.
The batch file must not go on to the next line (stopping the service)
until the application has finished. But
the help text from start /? says that when
command extensions are enabled, /wait is ignored for
32-bit programs — which Acronis is. So I needed to
disable “command extensions” while the batch file is running.
Windows help comes up with a list of irrelevant hits when I
search for “command extensions”. (There’s a
surprise ... not!) I did find the information I needed in the command prompt
via cmd /? and setlocal /?.
setlocal lets me disable disable extensions just
within this batch file, which is exactly what I want. An
endlocal at the end would be implied, but I like to spell
things out.
The net start and net stop
commands start and stop services. One interesting wrinkle is that
each service has two names,
its service name and its display name.
Sometimes, as with iTunes, they’re the same; but they can be
different, as they are with Acronis. You need the
service name from the Properties dialog,
not the display name. And if the service name contains any spaces, you
must enclose it in quotes on the command line.
I’ve seen Web advice to start and stop services with the
sc command, but that didn’t work for me.
Because iTunes is so ill behaved,
it’s not enough just to stop its services; you actually have to
disable them. If a service is disabled, iTunes can’t start
it — but neither can my batch file. So in the
iTunes batch file I have to enable the
service before trying to start it, then re-disable it after stopping
it. The sc config command will do that, but notice
that there are required spaces after start= and
stop=.
There’s an
error in the help text for start:
it marks the window title as optional, but in fact
it seems to be required.
The other issue is to know which program to launch. Start by right-clicking the program’s own shortcut in the start menu and selecting Properties → Shortcut → Target.
If the application has suppressed the path in that box, as iTunes does, then you’ll have to go exploring for it, probably in C:\Program Files or C:\Program Files (x86).
But even if there’s a path there, it might not be the
right executable. For example, the
Acronis TrueImage Home shortcut launches something called
TrueImageLauncher.exe, which sounds as though it should be right. But I discovered
that the /wait option didn’t
seem to be working, even after I disabled command extensions. It was a
newsgroup suggestion that revealed the answer: TrueImageLauncher is
just a launcher: all it does is start up the real program and
then exit. The batch file saw that TrueImageLauncher had finished, so
it went on to stop the service. The cure was to find the actual
program, TrueImage.exe, and put that in the batch file.
Either way, be prepared to do some exploring and testing to find the right application file to launch within the batch file.
The net start
command requires elevated privilege, and when run in a batch file
it must inherit that privilege from the batch file. This is why
each shortcut has to be set to run as administrator.
this page: http://oakroadsystems.com/tech/7service.htm
Was this page useful? Visit my other Technical Articles. Want to show your appreciation? Please donate a few bucks to the author.