Bat file running as admin does not work - Why?

Discussion in 'Windows 7 Help and Support' started by goshenBleeping, Jul 31, 2014.

  1. goshenBleeping

    goshenBleeping Active Member

    Joined:
    May 23, 2013
    Messages:
    9
    Likes Received:
    0
    I have a bat file with the following:

    echo " Starting Avira services"
    echo\
    net start "Avira Service Host"

    I am executing this bat file in a user account, not an admin account.
    I tried executing the bat file two ways:
    (1) Right click on bat file & "run as administrator"
    (2) Create shortcut to bat file & set Properties --> Advanced to run the shortcut as Administrator

    In both cases, Windows correctly asks for the admin password. I provide the password, press enter, & I briefly sees a window appear and then disappear. I do not see the line of text "Starting Avira services". The service does not start. Apparently there is something here that I do not understand. Can someone enlighten me?
     
  2. Fixer1234

    Fixer1234 Senior Member

    Joined:
    Aug 3, 2012
    Messages:
    481
    Likes Received:
    37
    It sounds like your bat file is working fine, the problem is with Avira. What happens if you open an elevated cmd window and enter the net start command there? (elevated cmd: type cmd in the Start menu search box, right-click on cmd.exe in the resulting list, and select run as administrator).
     
  3. goshenBleeping

    goshenBleeping Active Member

    Joined:
    May 23, 2013
    Messages:
    9
    Likes Received:
    0
    Actually if my bat file has the line
    echo "Hello David"
    I get the same result: I briefly sees a window appear and then disappear. I do not see the line of text "Hello David". So this has nothing to do with Avira. Any thoughts???
     
  4. Fixer1234

    Fixer1234 Senior Member

    Joined:
    Aug 3, 2012
    Messages:
    481
    Likes Received:
    37
    If you enter your command directly within the Start menu/Run window, it will run and exit (and disappear). Follow the instructions in the previous response to open an elevated command window. That will remain open until you close it. While it is open, you can see any messages the system produces and even run multiple commands.
     
  5. goshenBleeping

    goshenBleeping Active Member

    Joined:
    May 23, 2013
    Messages:
    9
    Likes Received:
    0
    Bat file:
    @echo off
    echo\
    echo "Hello David"
    echo\
    pause

    If I run this in an elevated command window or in an admin account, I see the text and the 'pause' - no errors. If I run this as Administrator (mouse right click), the window appears and immediately disappears.
     
  6. Fixer1234

    Fixer1234 Senior Member

    Joined:
    Aug 3, 2012
    Messages:
    481
    Likes Received:
    37
    It sounds like the discussion has gotten a little off track from what I meant in my original response, so let me back up. Your original problem was that you were trying to start Avira using a batch file. Execution was not successful and the action was too fleeting to see what was going wrong. I suggested a way to keep the execution window open so that you could see any activity or messages that might explain what was happening.

    My expectation is that the only way to keep a window open in that way is to open a command window and run the bat file there. Trying to run a bat file from the desktop or a Run window, regardless of administrator privileges will execute and exit (unless you use something like pause to prevent completion). Your description above seems to describe the pause command working when launching the file from the desktop, but only when logged on as administrator. If I understand that correctly, I'm surprised.

    If you are trying to use pause as an alternative way to keep the window open, it may not be a reliable way. Once you pass control to something else within the bat file, you may never get to the pause command.

    However, returning to your original issue, have you solved the Avira problem yet? If not, try opening a command window and then running your bat file from there. Get back to the forum with what happens.

    Having said that, let me ask a dumb question to understand what you're trying to accomplish. Is the Avira you are trying to run the antivirus program or something else? I don't use Avira, but it is rare for a program of this kind to require you to create a bat file. Are you trying to customize what runs or is there some problem you are trying to solve?

    You might be creating a very complicated job for yourself trying to manually control the program. There is typically some type of setup or configuration menu where you select what services you want. For a given service, there may be many pieces and dependencies. The components may need to be loaded in a specific order and every component might not show up in something like the Task Manager. Trying to load a specific piece by hand may not work (which could be why you experienced the original problem).
     

Share This Page

Loading...