Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Forums > General Discussion

Vista - How to make a batch file on starting and stopping services from command prompt ?

Reply
 
Old 08-12-2008   #1 (permalink)


VISTA ULTIMATE 32BIT
 
 

How to make a batch file on starting and stopping services from command prompt ?

does anyone know how to make a batch file where you could start ,disable , stop and manual for a service from the command prompt ?

for example instead of going to services.msc and right clicking on a service then clicking on properties then making the startup to be manual,automatic or disable . I could do with a batch file where i would just launch the batch file and it would make the startup to manual and then disable the service that i want to disable.

My System SpecsSystem Spec
Old 08-12-2008   #2 (permalink)


Vista Ultimate x64 SP1
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

Aside from the obvious, what is it you're trying to accomplish? What services do you want disabled at one time but not another?
My System SpecsSystem Spec
Old 08-12-2008   #3 (permalink)


Windows 7 Ultimate x64
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

net start <service name>

net stop <service name>
My System SpecsSystem Spec
Old 08-12-2008   #4 (permalink)


VISTA ULTIMATE 32BIT
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

I want to know how I could make a service start manually or autmatically or disable from a command prompt by making a batch file. Instead of right-clicking on a service then going to properties and then click on the down arrow on startup and point to "automatic,disable or manual". Its for work. I know about net start " service name " and net stop " service name " . I'm trying to have it where it disables a service and I could make it manual instead of automatic from the batch file.
My System SpecsSystem Spec
Old 08-12-2008   #5 (permalink)


Vista Ultimate x64 MAK, OpenSolaris 5, Gentoo 2008.1....
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

SC
My System SpecsSystem Spec
Old 08-12-2008   #6 (permalink)


Vista Ultimate x64 SP1
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

Seriously, I want to learn something here. I understand what you're trying to do, but what I want to know is why? What are the practical applications of doing this?
My System SpecsSystem Spec
Old 08-12-2008   #7 (permalink)


Vista Ultimate x64 MAK, OpenSolaris 5, Gentoo 2008.1....
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

Simple - an easy way to disable services - some services are in automatic mode and will auto start themselves even if you stop them - Indexing for example.
My System SpecsSystem Spec
Old 08-13-2008   #8 (permalink)


VISTA ULTIMATE 32BIT
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

Johngalt,
SC? What I'm trying to do is from the command prompt(cmd) is to make a service manual then disable it then start it again. I want that as a batch file .So when I run the batch file thats what it does. If you can tell me how that would be great.
My System SpecsSystem Spec
Old 08-13-2008   #9 (permalink)


Vista Ultimate x64 MAK, OpenSolaris 5, Gentoo 2008.1....
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

Did you bother to read that link?

Code:
DESCRIPTION:
        SC is a command line program used for communicating with the
        Service Control Manager and services.
USAGE:
        sc <server> [command] [service name] <option1> <option2>...


        The option <server> has the form "\\ServerName"
        Further help on commands can be obtained by typing: "sc [command]"
        Commands:
          query-----------Queries the status for a service, or
                          enumerates the status for types of services.
          queryex---------Queries the extended status for a service, or
                          enumerates the status for types of services.
          start-----------Starts a service.
          pause-----------Sends a PAUSE control request to a service.
          interrogate-----Sends an INTERROGATE control request to a service.
          continue--------Sends a CONTINUE control request to a service.
          stop------------Sends a STOP request to a service.
          config----------Changes the configuration of a service (persistent).
          description-----Changes the description of a service.
          failure---------Changes the actions taken by a service upon failure.
          failureflag-----Changes the failure actions flag of a service.
          sidtype---------Changes the service SID type of a service.
          privs-----------Changes the required privileges of a service.
          qc--------------Queries the configuration information for a service.
          qdescription----Queries the description for a service.
          qfailure--------Queries the actions taken by a service upon failure.
          qfailureflag----Queries the failure actions flag of a service.
          qsidtype--------Queries the service SID type of a service.
          qprivs----------Queries the required privileges of a service.
          delete----------Deletes a service (from the registry).
          create----------Creates a service. (adds it to the registry).
          control---------Sends a control to a service.
          sdshow----------Displays a service's security descriptor.
          sdset-----------Sets a service's security descriptor.
          showsid---------Displays the service SID string corresponding to an arbitrary name.
          GetDisplayName--Gets the DisplayName for a service.
          GetKeyName------Gets the ServiceKeyName for a service.
          EnumDepend------Enumerates Service Dependencies.

        The following commands don't require a service name:
        sc <server> <command> <option>
          boot------------(ok | bad) Indicates whether the last boot should
                          be saved as the last-known-good boot configuration
          Lock------------Locks the Service Database
          QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
        sc start MyService

Would you like to see help for the QUERY and QUERYEX commands? [ y | n ]:
My System SpecsSystem Spec
Old 08-13-2008   #10 (permalink)


VISTA ULTIMATE 32BIT
 
 

Re: How to make a batch file on starting and stopping services from command prompt ?

Quote  Quote: Originally Posted by johngalt View Post
Did you bother to read that link?

Code:
DESCRIPTION:
        SC is a command line program used for communicating with the
        Service Control Manager and services.
USAGE:
        sc <server> [command] [service name] <option1> <option2>...


        The option <server> has the form "\\ServerName"
        Further help on commands can be obtained by typing: "sc [command]"
        Commands:
          query-----------Queries the status for a service, or
                          enumerates the status for types of services.
          queryex---------Queries the extended status for a service, or
                          enumerates the status for types of services.
          start-----------Starts a service.
          pause-----------Sends a PAUSE control request to a service.
          interrogate-----Sends an INTERROGATE control request to a service.
          continue--------Sends a CONTINUE control request to a service.
          stop------------Sends a STOP request to a service.
          config----------Changes the configuration of a service (persistent).
          description-----Changes the description of a service.
          failure---------Changes the actions taken by a service upon failure.
          failureflag-----Changes the failure actions flag of a service.
          sidtype---------Changes the service SID type of a service.
          privs-----------Changes the required privileges of a service.
          qc--------------Queries the configuration information for a service.
          qdescription----Queries the description for a service.
          qfailure--------Queries the actions taken by a service upon failure.
          qfailureflag----Queries the failure actions flag of a service.
          qsidtype--------Queries the service SID type of a service.
          qprivs----------Queries the required privileges of a service.
          delete----------Deletes a service (from the registry).
          create----------Creates a service. (adds it to the registry).
          control---------Sends a control to a service.
          sdshow----------Displays a service's security descriptor.
          sdset-----------Sets a service's security descriptor.
          showsid---------Displays the service SID string corresponding to an arbitrary name.
          GetDisplayName--Gets the DisplayName for a service.
          GetKeyName------Gets the ServiceKeyName for a service.
          EnumDepend------Enumerates Service Dependencies.

        The following commands don't require a service name:
        sc <server> <command> <option>
          boot------------(ok | bad) Indicates whether the last boot should
                          be saved as the last-known-good boot configuration
          Lock------------Locks the Service Database
          QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
        sc start MyService

Would you like to see help for the QUERY and QUERYEX commands? [ y | n ]:
John,
Yes I did. Still stuck on how I would go about writing a .bat file so when I launch the .bat file. It makes a service to manual in the startup choice then disables it then starts it. By the way how did you get the entire thing from command prompt to show up from the SC /? I type that and it goes down but doesn't show me the top portion.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Starting & stopping services VB Script
Solved Make a command prompt run a command as soon as it opens? General Discussion
recovery from command prompt starting from install dvd Vista General
10 seconds delay when starting 'command prompt' Vista General
Get-WmiObject and starting/stopping remote services PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46