madbull Posted December 21, 2007 Share Posted December 21, 2007 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 More sharing options...
Arie Posted December 21, 2007 Share Posted December 21, 2007 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 More sharing options...
madbull Posted December 21, 2007 Author Share Posted December 21, 2007 (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 December 21, 2007 by madbull Link to comment Share on other sites More sharing options...
halaxa Posted December 21, 2007 Share Posted December 21, 2007 (edited) If you want to also kill any process, you can usetaskkillyou can type taskkill /?for more options Edited December 21, 2007 by halaxa Link to comment Share on other sites More sharing options...
madbull Posted December 21, 2007 Author Share Posted December 21, 2007 If you want to also kill any process, you can usetaskkillyou can type taskkill /?for more optionsThanks for that one. Has come in usefull already. Link to comment Share on other sites More sharing options...
Mordac85 Posted December 21, 2007 Share Posted December 21, 2007 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 spoolersc config spooler start= disabledReturns: [SC] ChangeServiceConfig SUCCESSJust 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 More sharing options...
madbull Posted December 31, 2007 Author Share Posted December 31, 2007 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, Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now