Jump to content

Batch File To Stop Services Etc.


madbull

Recommended Posts

I was wondering if anyone new how to stop and disable a service using a batch script.

I know you can delete, view etc usinc the "sc" command but i'm unsure if this can be used to disable a service.

Thanks.

Another thing regarding batch files and command line programs (shutdown, sc, user etc) say i want to use shutdown.exe but i do not have it in my "system32" folder but i do have a copy of it on my memeory stick (e:\) can i point to it using a batch file.

eg:

cd e: shutdown.exe (variables/options here).

Thanks again,

Link to comment
Share on other sites


I was wondering if anyone new how to stop and disable a service using a batch script.

I know you can delete, view etc usinc the "sc" command but i'm unsure if this can be used to disable a service.

NET STOP "ServiceName"

Another thing regarding batch files and command line programs (shutdown, sc, user etc) say i want to use shutdown.exe but i do not have it in my "system32" folder but i do have a copy of it on my memeory stick (e:\) can i point to it using a batch file.

If the file is in the same folder as the batch script, there is no need to specify the path to the file. If the file is not in the same folder as the batch script and the path to the file cannot change, you could simply launch it via START. For options, launch START /?. If the path can change, which is the case with most USB sticks as they're plug and play, you could alter the CD-ROM drive discovery script to always point at the correct USB drive. See the Unattended Guide here for the script.

Link to comment
Share on other sites

I was wondering if anyone new how to stop and disable a service using a batch script.

I know you can delete, view etc usinc the "sc" command but i'm unsure if this can be used to disable a service.

NET STOP "ServiceName"

Another thing regarding batch files and command line programs (shutdown, sc, user etc) say i want to use shutdown.exe but i do not have it in my "system32" folder but i do have a copy of it on my memeory stick (e:\) can i point to it using a batch file.

If the file is in the same folder as the batch script, there is no need to specify the path to the file. If the file is not in the same folder as the batch script and the path to the file cannot change, you could simply launch it via START. For options, launch START /?. If the path can change, which is the case with most USB sticks as they're plug and play, you could alter the CD-ROM drive discovery script to always point at the correct USB drive. See the Unattended Guide here for the script.

Wow thanks Arie,

I completly forgot about the "net stop" command although i have never used this one anyway.

But i will use this now, also i was wondering what the "net.exe" files main function is i have looked at tye help part using "cmd" it looks like it has multiple functions.

Also i am aware of the "net1.exe" file and was wondering whether this has anything to do with the "net.exe" file.

Thanks for all of the information you have supplied me,

PS. I am under the impression you know your batch files and commands, i was wondering if you would be able to help:

http://www.msfn.org/board/index.php?showtopic=109578 - removing a non empty directory.

Edited by madbull
Link to comment
Share on other sites

I was wondering if anyone new how to stop and disable a service using a batch script.

I know you can delete, view etc usinc the "sc" command but i'm unsure if this can be used to disable a service.

You can use SC to start/stop a service as well as disable it.

sc stop spooler
sc config spooler start= disabled

Returns: [SC] ChangeServiceConfig SUCCESS

Just beware that the space between the equal sign and disabled is not a typo. SC will bomb out if you don't use it.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...