none
Help starting and stopping services from batch file RRS feed

  • Question

  • Ok, this could be a long post as I am a scripting newb and want to make sure my question is clear.

    I am running windows 10. My goal is to make a user that launches into a batch file as a replacement shell. This much I have accomplished. The batch file is designed to change the power plan (accomplished) stop any unwanted processes and services (the part I am having trouble with), launch a program (Ableton Live) and wait for that program to close (accomplished) start whatever was stopped (I assume not working but not sure because services never stopped) and log out (accomplished)

    To stop services I have tried net stop, and sc stop. I have tried running a shortcut to the batch file with run as administrator ticked in the properties. I have tried using runas /user:administrator /env [path\filename.bat]. I keep getting the same error messages no matter what I do;

    with sc stop:

    [SC] OpenService FAILED 5:

    Access is denied.

    with net stop:

    System error 5 has occurred.

    Access is denied.

    Anyone have an Idea how I can gain administrator permission to exocute this scrip in an automated way so that I can set the batch file as the windows shell and have it run on user login without opening explorer.exe?

    Thursday, November 24, 2016 4:08 AM

Answers

All replies

  • update:

    I have read  /faq-why-cant-i-bypass-the-uac-prompt/  from this forum and am now assuming this is probably related to that. I am wondering if there is any "extreme" workaround I can use, as the computer is never connected to any network and is used solely as a music production platform.

    Thanks in advance if anyone can help me with this. I have been googling every solution I can imagine without any success.

    Thursday, November 24, 2016 4:25 AM
  • Post end user questions here: http://anwers.microsoft.com

    \_(ツ)_/

    Thursday, November 24, 2016 4:39 AM
  • Thank you Jrv, I understand there is a certain emount of knowledge expected before posting here. I have not posted on microsoft answers, but I have extensively searched it and found a post from someone trying to do the same thing (though for a different reason) which was not answered in a way that helped me. I will mark this as resolved and take off if you ask me to as I see you are a very senior person here, but perhaps you could direct me to another forum that helps with people like me other than microsoft answers? Or would it be out of line for me to leave this up for a few days and see i anyone bites? Thanks for your time and just let me know and I'll mark it answered.
    Thursday, November 24, 2016 7:24 AM
    • Marked as answer by Adam Mantium Thursday, November 24, 2016 7:40 AM
    Thursday, November 24, 2016 7:30 AM
  • Thanks.
    Thursday, November 24, 2016 7:41 AM
  • Oh by the way, that thing that can't be done; I did it.
    Wednesday, November 30, 2016 10:17 PM
  • Please tell how you were able to bypass the UAC prompt.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, November 30, 2016 10:52 PM
    Moderator
  • Please tell how you were able to bypass the UAC prompt.

    -- Bill Stewart [Bill_Stewart]

    I know of one good way.  45 caliber intimidation. 

    Or - switch to XP.

    How about removing all system security?


    \_(ツ)_/

    Wednesday, November 30, 2016 11:40 PM
  • Googled it.
    Sunday, December 4, 2016 8:41 PM
  • Provoking the UAC prompt is not the same thing as bypassing it.


    -- Bill Stewart [Bill_Stewart]

    Sunday, December 4, 2016 10:02 PM
    Moderator
  • fair enough, but it accomplished my goal.
    Sunday, December 4, 2016 11:37 PM
  • But you didn't state that as your goal. You asked how to bypass the UAC prompt. The answer to that question is "you cannot." If you were to ask how to provoke the UAC prompt, that is an entirely different question, and there are multiple ways to do that.

    -- Bill Stewart [Bill_Stewart]

    Monday, December 5, 2016 2:57 PM
    Moderator
  • hmm, nope. Never asked that. Read the OP
    Sunday, December 11, 2016 10:41 AM
  • hmm, nope. Never asked that. Read the OP

    In order to start and stop service you must run elevated as an administrator.  You cannot elevate from a batch file with RunAs or any other way without a UAC prompt.  YOU can force UAC with PowerShell or VBScript or with some utilities but you will still get the prompt.  "RunAs" cannot force elevation.


    \_(ツ)_/

    Sunday, December 11, 2016 11:38 AM