Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Prevent a service from starting up without disabling it?

29 Jan 2016   #1
sleepless

Windows 7 Ultimate x64 SP1
 
 
Prevent a service from starting up without disabling it?

Is there a way to prevent a service from starting up without disabling it completely. I want to be able to start/stop a service by using a .bat shortcut, but that doesn't seem to work if it's disabled. If I set to Manual, the service auto starts with startup. The service is "Function Discovery Resource Publication" - FDResPub.


My System SpecsSystem Spec
.
29 Jan 2016   #2
Lance1

Windows 7 Ultimate, Service Pack 1, 64 bit
 
 

There are some good suggestions here Stop and Start a service via batch or cmd file?
My System SpecsSystem Spec
29 Jan 2016   #3
sleepless

Windows 7 Ultimate x64 SP1
 
 

Quote   Quote: Originally Posted by Lance1 View Post
There are some good suggestions here Stop and Start a service via batch or cmd file?
well thanks, but nothing there answers my question.

-is it possible to start a service from a .bat if it's been disabled?
-is there a way to prevent a service from running on startup without disabling it?
My System SpecsSystem Spec
.

29 Jan 2016   #4
Lance1

Windows 7 Ultimate, Service Pack 1, 64 bit
 
 

-is it possible to start a service from a .bat if it's been disabled? NO

-is there a way to prevent a service from running on startup without disabling it? NO

That's the brunt of it.
My System SpecsSystem Spec
29 Jan 2016   #5
LMiller7

Windows 7 Pro 64 bit
 
 

Whenever something is as difficult as this a reasonable question is: Why do you wish to do this?
What are you trying to accomplish that requires such an unusual service configuration?
Maybe there is a better way.
My System SpecsSystem Spec
29 Jan 2016   #6
sleepless

Windows 7 Ultimate x64 SP1
 
 

Got it. Looks like it's a 2-step process. stop>disable>enable>start. This makes it pointless to run from a batch as it's just qucker to open a shortcut to services.msc and change the settings from there.

thanks.
My System SpecsSystem Spec
29 Jan 2016   #7
sleepless

Windows 7 Ultimate x64 SP1
 
 

Quote   Quote: Originally Posted by LMiller7 View Post
Whenever something is as difficult as this a reasonable question is: Why do you wish to do this?
What are you trying to accomplish that requires such an unusual service configuration?
Maybe there is a better way.
Simply, there's a service which I don't want to run on startup. I want to control when it runs it manually. I thought (wrongly) that setting the service to 'manual' would accomplish this. Instead it turns out I need to stop the service, then disable it This means it is a 2-step process to start it again also.

Is manually controlling a service really such an "unusual configuration"?
My System SpecsSystem Spec
29 Jan 2016   #8
MilesAhead

Windows 7 32 bit
 
 

I would think you could set the start type using SC command in batch, then run a delay to give it time to kick in. Then run the command to start it. Play around with sc.exe.

https://technet.microsoft.com/en-us/.../bb490995.aspx

Setting the delay in batch

4 Ways to Delay a Batch File - wikiHow
My System SpecsSystem Spec
30 Jan 2016   #9
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Quote   Quote: Originally Posted by sleepless View Post
-is it possible to start a service from a .bat if it's been disabled?
-is there a way to prevent a service from running on startup without disabling it?
No and no. But that doesn't mean there isn't a solution.

Triggering a service while its start mode is set to Disabled can be achieved by quickly setting the start mode to Enabled, starting the service, then Disabling the service again in quick succession. This'll work because, a disabled service cannot be started, however, a service that is disabled while it is running will continue to run until manually stopped.

E.g., assume the disabled service "RemoteRegistry". This service can be started using the below example batch file
Code:
@echo off
REM Starts a disabled service by first enabling it, starting it, then disabling it again.
REM Some services may require Run As Administrator to start.
 
REM Tested the script with 'RemoteRegistry' service.
set "service=RemoteRegistry"
REM Stop script execution if the service's start mode is not currently disabled
sc qc "%SERVICE%" | find "START_TYPE" | find "4" >NUL || (echo Start mode of given service is not disabled& exit /b 1)
REM Stop script execution if the service is already runnning
sc query "%SERVICE%" | find "STATE" | find "4" >NUL && (echo Service is already running& exit /b 1)
REM Set start mode of service to Manual
sc config "%SERVICE%" start=demand
REM Start the service
sc start "%SERVICE%"
REM Set service start mode back to Disabled
sc config "%SERVICE%" start=disabled

Quote   Quote: Originally Posted by sleepless View Post
[...] This makes it pointless to run from a batch as it's just qucker to open a shortcut to services.msc and change the settings from there.
I highly doubt the efficiency of your clicking competes with a script.

Quote   Quote: Originally Posted by sleepless View Post
I want to control when [the service] runs it manually. I thought (wrongly) that setting the service to 'manual' would accomplish this.
Ditto. There must a process explicitly requesting that your service be started. It's tricky to tell which process this is, and even then there is no way to prevent it from doing so.

Quote   Quote: Originally Posted by sleepless View Post
Is manually controlling a service really such an "unusual configuration"?
Depending on your goal; there may be a more optimal method.
My System SpecsSystem Spec
Reply

 Prevent a service from starting up without disabling it?




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Does disabling a service stop a scheduled task from running?
this is probably a dumb question, but if a service is disabled (HKLM\System\CurrentControlSet\Services), will that stop the scheduled task from running also? what if set to 'manual'?
Performance & Maintenance
(q) How can I prevent n application from disabling DWM and Glass?
One Windows 7 x64 computer in the fleet requires a software called "SuperDVR" (from "Q See Security", the only software that will work for the hardware) be used at all times. The problem is, as soon as the application starts, the theme changes back to the basic theme and it says something along the...
Software
Prevent CURSOR JUMPING by Disabling Touchpad on Your Laptop
Curse of the Jumping Cursor Greetings to all who have been suffering from this insane malady. I have brand-new (Sept. 2011) DELL Inspirion N4110 laptop running Windows 7 & a Dynex wireless mouse. Disabling the Touchpad fixed it. Here's a mini Troubleshooting Guide for any who may wish to use...
Hardware & Devices
Windows explorer switches prevent starting
Here is an odd problem. I was using windows explorer switches /n/e, /c:\ to make explorer start in classic view showing the root. In my named account, these switches prevent explorer from starting. take them away, and it starts fine. go to administrator account, and the switches...
General Discussion
Prevent automatic disabling of Aero
I filled out my list of hardware on the registration so I hope that suffices. In case it doesnt, however, I will just say that I have a computer more then capable of running windows aero and browsing the internet at the same time. So a simple google search tells me that this "slow performance"...
Themes and Styles
Network Location Awareness Service - Keeps disabling itself in Win7
Hi all, I have created a universal Windows 7 Pro 64-bit image. There are zero issues when using this image apart from one. When I add it to the domain, it seems to set the NLA service (Network Location Awareness) to Disabled when it was originally set to automatic. Now, I can set it back to...
Network & Sharing


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:39.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App