Run .BAT as admin without UAC prompt?

Page 1 of 3 123 LastLast

  1. Posts : 7
    Windows 10
       #1

    Run .BAT as admin without UAC prompt?


    Edit: Marked as "Solved", because it looks like under Win 10 I can no longer do this quite the way I used to in Win 7, and I have multiple suggestions as to alternate approaches, any one of which ought to work.

    ((Moved from the "General" forum))

    Can anyone help? I am trying to run a .BAT script that needs admin privileges, and I need to lose the annoying UAC prompt. I found out how to do that under Win 7, but can't get the same approach to work under Win 10.

    I have created a task with "Run with highest privileges" to start my script. I then attempt to start it from a desktop shortcut. That works fine under WIn 7, and I've seen a couple of tutorials saying that it works under WIn 10 as well - but I can't get it to.

    If I run the new task from within Task Scheduler, to check it out, it does exactly what I expect it to.

    When I simply attempt to run it from the desktop shortcut (using a command of format schtasks /run /tn "mytask"), though, all that happens is that a window of some sort pops and disappears way too fast for me to see what it is trying to tell me (I've tried looking in event viewer for some sort of indication as to what it's objecting to, but can't see anything relevant). Under Win7, my script would execute successfully at this point.

    If I finally cave in and choose to launch the shortcut with "Run as Administrator", the script executes OK - but that merely triggers the very UAC prompt I'm trying to avoid.

    The account I'm using is an administrator. My script, amongst other things, executes runas.exe to launch a .EXE file under a second admin account.

    Any bright ideas? Or other ways to achieve the same result?
    Last edited by Doghouse; 13 Feb 2017 at 04:52.
      My Computer


  2. Posts : 4,144
    Windows 3.1 to Windows 11
       #2

    You could disable UAC via control panel...

    I have a lot of scripts that bypass the admin - but UAC always pops-up
      My Computer


  3. Posts : 7
    Windows 10
    Thread Starter
       #3

    Kyhi said:
    You could disable UAC via control panel...
    I could, sure. But that's a bit like cutting off a leg because you've lost your toenail clippers. In principle I'm happy with UAC being on. This is for something I run regularly, and trust; I was looking for something a little less... ...extreme.

    Plus, frankly, it's frustrating that something that worked OK under Win 7 doesn't seem to want to work under Win 10, when it's not obvious why it shouldn't (and when other people also seem to think that it still should). I'd like, if I can, to understand why, and whether it can be made to.
    Last edited by Doghouse; 10 Feb 2017 at 03:40.
      My Computer


  4. Posts : 19,518
    W11+W11 Developer Insider + Linux
       #4

    It's part of tightened security in W10. Can't have both security and letting anything to run loose without at least a warning.
      My Computers


  5. Posts : 2,799
    Linux Mint 20.1 Win10Prox64
       #5

    Create a reg file with code below and merge into the registry to avoid UAC prompt from bat file:
    Windows Registry Editor Version 5.00

    Code:
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{E2F13B98-650F-47DB-845A-420A1ED34EC7}User\Software\Microsoft\Windows\CurrentVersion\Policies\Associations]
    "LowRiskFileTypes"=".exe;.bat;.cmd;.vbs"
    
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Associations]
    "LowRiskFileTypes"=".exe;.bat;.cmd;.vbs"
      My Computer


  6. Posts : 856
    Windows 10 Pro 21H2 build 19045.2193 Dual Boot Linux Mint
       #6

    Compile the bat file and create it as an exe and the problem should go away. I use Batch Compiler Batch Compiler | Home | Freeware IDE compile convert bat to exe advance batch commands debugger and resources
      My Computers


  7. Posts : 7
    Windows 10
    Thread Starter
       #7

    CountMike said:
    It's part of tightened security in W10. Can't have both security and letting anything to run loose without at least a warning.
    Except that I can set a trigger on my task and have it run (say, at a time of my choosing) successfully, without further interaction, and without a prompt. Or run it straight from the Task Scheduler. But if I want to launch it conveniently...?

    Apparently, even though I'm an admin, I'm not safe with matches.
      My Computer


  8. Posts : 7
    Windows 10
    Thread Starter
       #8

    topgundcp said:
    Create a reg file with code below and merge into the registry
    Thanks. If all else fails, I'll probably go that route.
      My Computer


  9. Posts : 7
    Windows 10
    Thread Starter
       #9

    clam1952 said:
    Compile the bat file and create it as an exe and the problem should go away. I use Batch Compiler Batch Compiler | Home | Freeware IDE compile convert bat to exe advance batch commands debugger and resources
    Thanks, I'll take a look.

    (Edit: Haven't tried this yet, but you're probably right that this should work; plenty of people discuss taking this approach, but every reference I see now talks about "programs". I guess that WIn 7 was slightly more lax in allowing .BAT as well.)
    Last edited by Doghouse; 13 Feb 2017 at 04:50.
      My Computer


  10. Posts : 4,144
    Windows 3.1 to Windows 11
       #10

    Guess, I'll have to do a little testing with the suggestions above, as well...
    Thanks..
      My Computer


 

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

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




Windows 10 Forums