How to run Batch File as Admin?

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #11

    AlexRD said:
    Captain Zero said:
    Make a shortcut to the bat?
    Tried that, but the Run as Admin still greyed.
    Right click on the shortcut and select the 'shortcut' tab (not the compatibility tab), then click Advanced. Here you will find ANOTHER Run as Administrator option that is just for shortcuts.
      My Computer


  2. Posts : 9
    Win 7 Ultimate 32bit
       #12

    this works...thanks a lot
      My Computer


  3. Posts : 2
    Windows 7 32bit
       #13

    I wrote a bat script example which prompts for admin access and then continues. I hope it helps some... jagaroth: admin access prompt for batch files
      My Computer


  4. Posts : 3
    Windows 7 Pro 64bit
       #14

    TimStitt said:
    AlexRD said:
    Captain Zero said:
    Make a shortcut to the bat?
    Tried that, but the Run as Admin still greyed.
    Right click on the shortcut and select the 'shortcut' tab (not the compatibility tab), then click Advanced. Here you will find ANOTHER Run as Administrator option that is just for shortcuts.

    this one worked. thanks a lot.
      My Computer


  5. Posts : 7
    Windows 7 Ultimate 64-bit
       #15

    AlexRD said:
    Hello,

    I want to know how can i run a Batch File (.bat) as administrator since the Run as Administrator Checkbox in Compatibility tab is gray (can't check)?
    This is the Batch File:
    @echo off
    cd /d "C:\Program Files (x86)\Ubisoft\Far Cry 2\bin"
    start /realtime FarCry2.exe

    Should i put something like Start as admin /realtime ???

    Thanks,
    Alex.
    Make a shortcut to the .bat, right click, go to properties, in the "Shortcut" tap click on advanced, then you can check off "Run As Administrator". Your Welcome.
      My Computer


  6. Posts : 1
    Windows 7 Professional x64
       #16

    Just what I had been looking for


    After reading this thread I kept going because I didn't want to make a shortcut. I came across a solution that worked well for me and thought I would pass it on. You may put a bit of code at the top of the batch file and it will prompt UAC for admin elevation. The code and explanation of how it works can be found here.

    I hope this helps someone as much as it helped me.
      My Computer


  7. Posts : 1
    Windows 8.1 x64
       #17

    After reading this thread I kept going because I didn't want to make a shortcut. I came across a solution that worked well for me and thought I would pass it on. You may put a bit of code at the top of the batch file and it will prompt UAC for admin elevation. The code and explanation of how it works can be found here.

    I hope this helps someone as much as it helped me.
    @gagruk - Made an account just to thank you bro, saved me tonnes of time searching for this.
      My Computer


  8. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #18

    Hello all,

    I present the following batch snippet. It is a one line-er for prompting a UAC dialog box to the user, within a batch file, should the batch script not already be running with Administrative privileges to begin with. And you heard me correctly: ONE. LINE. SOLUTION!

    Excuse my excitement, but any batch scripter would know, this is pretty amazingly compact for what it does:

    Code:
    net session >NUL 2>&1|| powershell Start-Process '%0' -Verb RunAs&& exit /b|| exit /b
    Simply place the above line at the top of your batch script, immediately after "@echo off".

    This solution involves no third party tools, no Runas command, no registry lookups/changes, and certainty no temp files. Flawless. It's the real-deal.

    Akin to all other techniques found on the Web, this works by making a call to an alternate Windows scripting language that is capable of starting processes with elevated (Administrator) permissions. The reason why the above line of batch script does not require temporary files (and thus only one line in length) is because unlike most other solutions that take advantage of VBScript--which all it's code must be packed into a .vbs file to run--, the solution presented above takes advantage of Windows PowerShell. It is possible to make calls to PowerShell's Cmdlets within batch itself, so no need of generating a temporary script file.


    Say "no" to "admin" shortcuts to batch files.
    And never disable UAC as a solution!
    Last edited by Pyprohly; 24 Jan 2015 at 22:38. Reason: Fixed: Spaces in paths break command line
      My Computer


  9. Posts : 1
    Windows 7 Ultimate x64
       #19

    Sir, I've just created an account to thank you.
    I've been looking for this.
      My Computer


  10. Posts : 25,847
    Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
       #20

    Thanks for joining usernamewastake.
      My Computer


 
Page 2 of 3 FirstFirst 123 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 22:48.
Find Us