Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Script to stop services

  • 22-02-2011 8:23pm
    #1
    Closed Accounts Posts: 37


    Hi.

    I have a laptop and spend a lot of time travelling where I have no power source other than my battery. I can extend the battery life by a factor of two by turning off unnecessary services but it's a pain doing it manually. I'd like to write a simple script/batch file to switch off the unnecessary services but I'm receiving an error when I try this on the command line. I receive no errors doing it through the services.msc UI. It's something to do with the 'Local Services' account but I'm not sure what. I am a member of the Admin group. The error is:

    Error 1079: The account specified for this service is different from the account specified for other services running in the same process.

    There are no passwords on any accounts. Might this be the problem? IIS is not installed or any of its ancillary services e.g. ftp publishing etc.
    TVM


Comments

  • Closed Accounts Posts: 16,339 ✭✭✭✭tman


    Should just be a case of making a batch file with "net stop servicename" for each service you want to stop, then ensuring you right click and run as admin

    Just made a batch file with the following and it worked for me no bother;

    @echo off
    net stop EventSystem
    pause


  • Moderators, Arts Moderators, Regional Abroad Moderators Posts: 11,106 Mod ✭✭✭✭Fysh


    What version of windows are you running?

    I've just tested the following on Windows 7 and it works fine:
    To stop services:
    
    echo Stoppping specified services...
    net stop Webclient
    net stop Fax
    echo All specified services stopped.
    pause
    
    To start services:
    
    echo Stoppping specified services...
    net stop Webclient
    net stop Fax
    echo All specified services stopped.
    pause
    

    Save each as a .bat on the desktop, run as administrator and it works fine.

    If you're on XP you may have to try and get clever with using runas to specify the LocalService account when starting/stopping the services. Don't forget you'll also need to wrap any multi-word service names in speech marks.


  • Closed Accounts Posts: 37 ggrr1970


    Sorry. Prob should have given some more info. The 'net stop' works with the more regular services but if you try it with some of the less regular ones you will get the error e.g. Adaptive Brightness service - SensrSvc. Prob should've mentioned that this occurs on W7
    ~Thx


  • Closed Accounts Posts: 16,339 ✭✭✭✭tman


    You're definitely right clicking on the command prompt and running as admin beforehand?


  • Closed Accounts Posts: 37 ggrr1970


    I tried running under the Local System Account in the Log On tab but I see the same error.
    How do I right click/run as within the command line?


  • Advertisement
  • Closed Accounts Posts: 16,339 ✭✭✭✭tman


    As in type "cmd" into the search bar, right click on the command prompt icon before launching it and choose run as administrator, then do the "net stop xxxxx" bit


  • Moderators, Arts Moderators, Regional Abroad Moderators Posts: 11,106 Mod ✭✭✭✭Fysh


    If you've saved your batch files or cmdlets on the desktop, you can right-click them and select Run As Administrator there. If you don't do this, the files and any commands they contain will run as a non-elevated user.


  • Closed Accounts Posts: 37 ggrr1970


    Ahh. Sorry. Okay, I see what you mean but the thing is I want to write a batch file (stop.bat) to stop the services. How would I assign 'Run As' to the script? Apols if I seem like an idiot but am a UNIX head.

    Pesky Windows
    thx again


  • Closed Accounts Posts: 37 ggrr1970


    Sorry Fysh. just saw yours. Will try


  • Closed Accounts Posts: 37 ggrr1970


    Okay. Tried that but same result. Tried via the gui and the cl. Same error.

    System error 5 has occurred.

    Access is denied.

    Can you verify with SensrSvc service on W7?
    Thx


  • Advertisement
  • Moderators, Arts Moderators, Regional Abroad Moderators Posts: 11,106 Mod ✭✭✭✭Fysh


    ggrr1970 wrote: »
    Okay. Tried that but same result. Tried via the gui and the cl. Same error.

    System error 5 has occurred.

    Access is denied.

    Can you verify with SensrSvc service on W7?
    Thx

    Yep, just verified that it works using the same layout as above - saved the code as stopservice.bat on the desktop, right-clicked and selected Run As Administrator, and a command prompt appears showing the status of each service being started or stopped.


  • Moderators, Arts Moderators, Regional Abroad Moderators Posts: 11,106 Mod ✭✭✭✭Fysh


    I've just stumbled across Sudo for Windows which might be of interest to you if you're more familiar with Linux than Windows. I've not used it, but it might help you get Windows working under a more familiar security model.

    Edited to add:

    There are also some Script Elevation PowerToys which be very handy for this sort of thing. I've not used them yet but will definitely be tinkering in the next few days...


Advertisement