Jump to content

run as adminstrator works only interactively?


jeffw_00

Recommended Posts

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 by jeffw_00
Link to comment
Share on other sites

  • 4 months later...

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'.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...