jeffw_00 Posted August 23, 2021 Share Posted August 23, 2021 (edited) Hi - I am protecting a file using cacls <file> /P everyone:R < y.txt and later unprotecting it via cacls <file> /P everyone:F < y.txt The problem is this - I can run the 2nd command interactively in a CMD window created using "Run as Administrator", but when I put that command in a .BAT file, and try to run that .BAT file from a regular CMD window by giving the shortcut elevated privileges, the facilities for doing so in Windows 10 don't seem to work. I created a CMD.EXE shortcut and set "Run as Administrator" both in the "Shortcut -> Advanced" and "Compatibility" tabs, but it doesn't seem to give the command the needed privilege. I eventually want to run this from task scheduler and so I even tried firing the shortcut from there with "highest privileges'" but that didn't work either. There are other ways to complete my overall task, but it bothers me that this doesn't seem to work. Without creating an admin account with a password (to use runas) does anyone know why these "Run as Administrator" options do not have the same effect as creating a "Run as Administrator" CMD window? I spent an hour on a web-search - there are some VBS and third-party exe solutions that were dated and I couldn't get working. What I'm really observing is that the elevated shortcut works -sometimes- and oddly doesn't work other times - (no pattern I can find yet) I put it in my scripts in a few places running on different machines all at once, and some succeeded and some failed. Just wondering if someone has a solid solution. (or has found one of my solutions to work solidly and then I will dig deeper on this end). Thanks! /j Edited August 23, 2021 by jeffw_00 Quote Link to comment Share on other sites More sharing options...
xrobwx71 Posted January 20, 2022 Share Posted January 20, 2022 I know this is an older post but for future travelers with the same question, I found this and tested it, it works. https://www.winhelponline.com/blog/automatically-elevate-batch-file-run-administrator/#:~:text=To elevate batch files manually,right-clicking a batch file. 2 Quote Link to comment Share on other sites More sharing options...
crp Posted January 23, 2022 Share Posted January 23, 2022 if you are putting the batch file in a task scheduler you don't need to do anything special with the file. Run the batch file as an administrator and check the box for 'highest privilege'. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.