Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:53:34+00:00 2026-06-12T16:53:34+00:00

I am trying to amend the ACL on a file using icacls. I want

  • 0

I am trying to amend the ACL on a file using icacls. I want this file to be owned by Administrator and be accessible to Administrator only. I found out how to make administrator the owner of the files, and I know how to remove a group from the security list but I don’t know how to remove all groups but the administrator group if I don’t know the name of the other groups.

I am looking for a way to tell Windows that I only want to let Administrator access the file and remove any other user/group if there is any.

I tried using the wildcard character but it doesn’t work.

Here’s my script:

$domain     = [Environment]::UserDomainName
$user       = [Environment]::UserName
icacls $myinvocation.mycommand.path /setowner "$domain\$user" /T
icacls $myinvocation.mycommand.path /grant "$domain\$user"

icacls $myinvocation.mycommand.path
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:53:35+00:00Added an answer on June 12, 2026 at 4:53 pm

    In theory, you can use :r after grant (see Docs). However, in practice I couldn’t make this work. I think :r means “Replace permisions only for the specified user“.

    I’ve tested the following solution in Powershell and it works fine though.

    # Reset the folder to just it's inherited permissions
    icaclsname c:\temp\test /reset 
    
    # Then, disable inheritance and remove all inherited permissions
    icacls c:\temp\test /inheritance:r
    
    # Note the :r after grant. It's not now needed, but I've left it in anyway.
    # Permissions replace previously granted explicit permissions.
    # Also note the :F, where : is escaped with `. This grants FULL CONTROL.
    # You can replace F with whatever level of control is required for you.
    icacls c:\temp\test /grant:r $domain\$user`:F
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to figure out how I can do this properly. The print_r looks like
trying to figure out why this is happening - I have an input text
I'm trying to write a file using the FileOutputStream and OutputStreamWriter but I keep
I am trying to amend codeigniters' file uploader class so the filename of every
I'm trying to parse and amend some html (as a string) using javascript and
I'm trying to amend the height of a footer using below css. If I
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Trying to use/learn git with a personal project. There's only me and a remote
I am trying to format the contents of a text box: this.lblSearchResults1.Text = Convert.ToDouble(lblSearchResults1.Text).ToString();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.