Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2116
  • Last Modified:

How do you disable services from the CMD line

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
sawred
Asked:
sawred
  • 5
  • 3
  • 3
  • +2
1 Solution
 
oBdACommented:
That can be done with sc.exe from the Resource Kit.
sc.exe config <servicename> start= disabled.
0
 
SunBowCommented:
done?
0
 
sawredAuthor Commented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sawredAuthor Commented:
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
 
sawredAuthor Commented:
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
 
oBdACommented:
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
 
DominicCroninCommented:
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
 
DominicCroninCommented:
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
 
sawredAuthor Commented:
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
 
DominicCroninCommented:
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
 
Bazz_The_CatCommented:
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
 
Bazz_The_CatCommented:
but of course, the best way is with sc.exe
0
 
sawredAuthor Commented:
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
 
oBdACommented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now