?
Solved

How do you disable services from the CMD line

Posted on 2003-03-21
14
Medium Priority
?
2,103 Views
Last Modified: 2013-12-04
I setup a lot of XP machines, and I have to disable 10 services.  I am not allowed to use an image or ghost type application, and have to do all these machines manually.  I would like way to disable services from the CMD line, a batch file, a reg key something, anything where I can run 1 thing and it knocks out 10 services.
0
Comment
Question by:sawred
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +2
14 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 80 total points
ID: 8183955
That can be done with sc.exe from the Resource Kit.
sc.exe config <servicename> start= disabled.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 8184055
done?
0
 

Author Comment

by:sawred
ID: 8184344
oBda I cannot tell you how 'cool' I think you are.  Thanks a lot.

Thanks to you I found this http://support.microsoft.com/?kbid=251192
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:sawred
ID: 8184564
Okay oBda, I got 1 to work so far.  But I have another question

This is from M$
Servicename
Specifies the name given to the service key in the Registry. Note that this is different from the display name, which is what you see with NET START and the Services Control Panel application. SC uses the service key name as the primary identifier for the service.


*** Where do you find the last part, service key name for each service? ***

I am trying to disable Fast User Switching, and Help and Support, am I to understand that svhost.exe calls netsvcs?
Is it a 2 parter, or let me rephrase the question,

Fast User Switching Compatibility
C:\WINDOWS\System32\svchost.exe -k netsvcs
&
Help and Support
C:\WINDOWS\System32\svchost.exe -k netsvcs

A couple of times I got
"(SC) OpenService failed 1060"  might have typed it incorrectly

This one worked
sc config defwatch start= disabled
0
 

Author Comment

by:sawred
ID: 8184612
Okay oBda, I got 1 to work so far.  But I have another question

This is from M$
Servicename
Specifies the name given to the service key in the Registry. Note that this is different from the display name, which is what you see with NET START and the Services Control Panel application. SC uses the service key name as the primary identifier for the service.


*** Where do you find the last part, service key name for each service? ***

I am trying to disable Fast User Switching, and Help and Support, am I to understand that svhost.exe calls netsvcs?
Is it a 2 parter, or let me rephrase the question,

Fast User Switching Compatibility
C:\WINDOWS\System32\svchost.exe -k netsvcs
&
Help and Support
C:\WINDOWS\System32\svchost.exe -k netsvcs

A couple of times I got
"(SC) OpenService failed 1060"  might have typed it incorrectly

This one worked
sc config defwatch start= disabled
0
 
LVL 85

Expert Comment

by:oBdA
ID: 8187907
The service key name can be identified using 'sc query'. You probably need to enlarge the buffersize, and you might want to pipe it through find, so that you just have a list of names.
That would turn out to be 'sc query bufsize= 4096 | find /i "service_name"'
0
 
LVL 6

Expert Comment

by:DominicCronin
ID: 8189982
Here's another approach using WMI:

set wmiService = GetObject ("winmgmts:Win32_Service.Name='FastUserSwitchingCompatibility'")
If wmiService.State = "Running" then
      wmiService.StopService()
End if
wmiService.ChangeStartMode("Disabled")
set wmiService = Nothing

You can also use the Win32_Service object to find out more things about a service than it's decent to ask :-)

More details at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_service.asp
0
 
LVL 6

Expert Comment

by:DominicCronin
ID: 8190001
And for the follow-up question, this might work.

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objServices = objWMIService.ExecQuery("Select * from Win32_Service",,48)

For Each objItem in objServices
    Wscript.Echo "============================"
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "DisplayName: " & objItem.DisplayName
    Wscript.Echo "Name: " & objItem.Name
Next
0
 

Author Comment

by:sawred
ID: 8195652
Ok I got it all working except for 3 of them

1.Fast User Switching Compatibility
2.Portable Media Serial Number Service
3.Universal Plug and Play Device Host

I cannot find the service name for these 3. Any help would be great.  

I am confused as to getting "sc query" working
And
those last 2 comments by DominicCronin look great, and I've had some programming but I don't know what WMI is? Requirements?  etc.
0
 
LVL 6

Expert Comment

by:DominicCronin
ID: 8197155
WMI = Windows management instrumentation

It's certainly part of the system in Win2K - I suspect you have to install it on older systems. To run the scripts above, copy and paste them into a text file, and give it a name with the extension .vbs

You can run them interactively, but in that case Wscript.Echo will generate a message box alert, which could get a bit tiresome! It's probably better to run them from a command prompt using the cscript command. For example:

cscript services.vbs

As for the names - on my system, running the above script reveals:

FastUserSwitchingCompatibility
WmdmPmSN
upnphost

This information is also available in the properties screen of the Services management snap-in (at least on my machine, which is running XP)
0
 

Expert Comment

by:Bazz_The_Cat
ID: 8211786
You can use the net service command line (in a batch)
or delete the appropriate entries in the registry with reg4.exe.

HKLM\SYSTEM\CurrentControlSet\Services\...
0
 

Expert Comment

by:Bazz_The_Cat
ID: 8211793
but of course, the best way is with sc.exe
0
 

Author Comment

by:sawred
ID: 8212252
Hey thanks everyone for your help

Thanks for the SC.EXE
Thanks for the Scripts
Thanks for the know how

All of it, my last questions are
What are the points on this board for?
What is the incentive?
How do I assign the points to everyone here that gave me an answer?

Below is a working example of the batch I made as well as turning this into a .com file. So everyone who reads it hear is the last place I am showing it.

This stops the service and disables it.

@echo off
cls
echo Disabling services now ....
echo now attempting to stop Help and Support
net stop "help and support"
sc config helpsvc start= disabled
echo Help and Support Disabled
echo ....

REM
REM


echo Now disabling NetMeeting Remote Desktop Sharing
sc config mnmsrvc start= disabled
echo Doesn't that feel nice
echo ....

REM
REM

echo Please stop mr automatic update
net stop "automatic updates"

echo No more Automatic Updates
sc config wuauserv start= disabled

echo System Restore Service now stopping
net stop "System Restore Service"
echo System Restore Now
sc config srservice start= disabled
echo OFF!!!

net stop "Smart Card"
sc config SCardSvr start= disabled

net stop "Error Reporting Service"
sc config ersvc start= auto

net stop "Smart Card Helper"
sc config SCardDrv start= disabled

net stop "SSDP Discovery Service"
sc config SSDPSRV start= disabled

net stop "themes"
sc config themes start= disabled



sc config "PolicyAgent" start= demand

net stop "Fast User Switching Compatibility"
sc config FastUserSwitchingCompatibility start= disabled
net stop "Portable Media Serial Number Service"
sc config WmdmPmSN start= disabled
net stop "Universal Plug and Play Device Host"
sc config upnphost start= disabled
0
 
LVL 85

Expert Comment

by:oBdA
ID: 8220494
The points are just there to be collected for the ones who answer for no particular reason other than to pile them up and to keep people from asking incessantly, because you only get so much (without paying).
To assign the points, you just accept the comment that helped you most as answer.
If you want to spend some additional points, you just open a new question worth the points, call it something like "points for <whoever>", wait for <whoever> to answer and then just accept it.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question