Jump to content

Batch File To Stop Services Etc.


Recommended Posts

Posted

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,


Posted
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.

Posted (edited)
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
Posted (edited)

If you want to also kill any process, you can use

taskkill

you can type

taskkill /?

for more options

Edited by halaxa
Posted
If you want to also kill any process, you can use

taskkill

you can type

taskkill /?

for more options

Thanks for that one. Has come in usefull already.

Posted
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.

  • 2 weeks later...
Posted

Thanks to everyone for their replies,

I am familiar with many of the suggested commands etc but have learnt alot of things that i didn't know and also advanced stuff about those that i did.

Once again Thanks,

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

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