reset ntfs partition permissions

What other productivity software are you working with...
yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

reset ntfs partition permissions

Post by yusef88 »

hi
i need a tool can integrate to right click menu and reset ntfs permissions for files and folders any suggestions?
===
windows xp

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: reset ntfs partition permissions

Post by Marco »

So no command line?
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: reset ntfs partition permissions

Post by yusef88 »

well, it will be good if it can reset the entire partition
====
even individual folders it would be good :x
Last edited by yusef88 on 14 Jul 2014 21:30, edited 1 time in total.

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: reset ntfs partition permissions

Post by Marco »

I was lucky to download FileACL 3.0.1.6 some years ago, when the website was still up. http://archive.today/pnb1o
These are the line that I use, in sequence, to totally reset the permissions of a drive X. You have to run them with admin privileges.

Code: Select all

fileacl X:\ /o Administrator /sub /files /force
fileacl X:\ /s Administrator:F /replace /force
fileacl X:\ /replace /inherit /noroot /sub /files /force
Attachments
Fileacl 3.0.1.6.zip
(176.86 KiB) Downloaded 349 times
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: reset ntfs partition permissions

Post by yusef88 »

wow, very easy to use.very thanks dear Marco
==
if i put it in <xydata> directory possible to make it work with selected folders by XY scripts?
=
or for simplification, make the script let me choose which drive letter to reset

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: reset ntfs partition permissions

Post by Marco »

Yes
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: reset ntfs partition permissions

Post by yusef88 »

small problem i just test it on a folder, after applying to 2 partitions i lost access to them and i had to restore their permissions manually :roll:
Attachments
2.png
2.png (30.38 KiB) Viewed 5568 times

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: reset ntfs partition permissions

Post by Marco »

Natural. You first reset the permissions with those lines: the Admin obtains full access. Then you should grant full access to yourself as well.
You could also try by substituting Administrator with Everyone in those lines (never tested myself tho).
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: reset ntfs partition permissions

Post by yusef88 »

i found something interesting "Bypass NTFS permissions" http://www.hobeanu.com/accessgain/
now i need your help :) to make this command work with selected folder

Code: Select all

CACLS folderpass /t /C /G Everyone:F
=====
update i made a batch file and use it by openwith script :D
ه really appreciate your help Marco :whistle:

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: reset ntfs partition permissions

Post by highend »

Code: Select all

    foreach($folder, "<get SelectedItemsPathNames |>", "|") {
        if (exists($folder) == 2) { run """%COMSPEC%"" /k CACLS ""$folder"" /T /C /G Everyone:F", 2, 0; }
    }
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: reset ntfs partition permissions

Post by yusef88 »

good script..thanks highend :appl:

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: reset ntfs partition permissions

Post by highend »

I'm currently writing something more "sophisticated"...

It uses ICALCS (CALCS is deprecated since Vista...)
but it will need a helper application (because I don't use
an elevated XY instance all the time).

Let's see if I can solve it with a small .vbs script (no external tool would be required).

Btw, if the current "script" works for you, you should replace the "/k" with "/c" at least
if you don't want to create a lot of dos boxes when you select more than one folder.
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: reset ntfs partition permissions

Post by yusef88 »

it works with folders only, this batch works with both files and folders and show if access is denied

Code: Select all

@echo off
:a
if exist "%~1\nul" cd /d %1&set sub=/T
title ResetNTFSPermissions CACLS
echo This will REPLACE all the NTFS permissions to EVERYONE incuding all subfolders
echo (or run the command manually with /E to Edit ACL instead of replacing it)
echo ---
echo CACLS %1 %sub% /C /G Everyone:F
echo ---
CACLS %1 %sub% /t /C /G Everyone:F
shift
set g=hiren%1
if %g%==hiren goto e
goto a
:e
Pause

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: reset ntfs partition permissions

Post by highend »

1. Autoelevating
2. Translations
3. Could be enhanced with an inputselect() to decide which commands should be executed

Code: Select all

    /*
        /T = Recusive
        /C = Continue in case of any file errors
        /Q = Don't show a message for each file / folder
        /grant:r = Replace permissions instead of adding them
        (OI) = Object inheritance (Vererbung für Dateien)
        (CI) = Container inheritance (Vererbung für Ordner)
        F = Full
    */

    // End if no files / folders are selected
    $selectedItems = "<get SelectedItemsPathNames |>";
    if ($selectedItems == "") {
        status "No item(s) selected, aborted!", "FF0000", "stop";
        end(true);
    }

    $batFile = "%TEMP%\~icacls.bat";
    $getAdminVBSFile = "%TEMP%\~GetAdmin.vbs";

    // Get client language
    $languageID = regexmatches(runret("""%COMSPEC%"" /c REG QUERY ""HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language"" /v ""InstallLanguage"""), "\d{4}");

    // Translation
    $groupList = "Administrators|Users|Everyone";
    if ($languageID == "0407") { // German
        $localizedGroupList = "Administratoren|Benutzer|Jeder";
    } else { // Fallback to english
        $localizedGroupList = $groupList;
    }

    // Possible ICACLS commands
    $acl_Options = " /T /C /Q";
    $acl_Reset_Full = replacelist("/grant:r Everyone:(OI)(CI)F", $groupList, $localizedGroupList, "|");
    $acl_Add_Admin = replacelist("/grant Administrators:(OI)(CI)F", $groupList, $localizedGroupList, "|");
    $acl_Add_CurUser = "/grant %USERNAME%:(OI)(CI)F";

    // Edit this list if you want to add / remove commands to process
    // Ofc you need to add additional variables right over this comment...
    $aclProcessList = '$acl_Reset_Full|$acl_Add_Admin|$acl_Add_CurUser';

    $batchCommands = "";
    foreach($item, $selectedItems, "|") {
        $cmdOptions = "";
        foreach($entry, $aclProcessList, "|") {
            $entry = eval($entry); // Resove the variable names
            $cmd = "@ICACLS " . quote($item) . " " . $entry . $acl_Options;
            $cmdOptions = $cmdOptions . "@ECHO [Options: $entry]<crlf>" . $cmd . "<crlf>" . "@ECHO." . "<crlf>";
        }
        $batchCommands = $batchCommands . "@ECHO [$item]<crlf>" . $cmdOptions . "<crlf>" . "@ECHO.<crlf>@ECHO.<crlf>";
    }

    writefile($batFile, $batchCommands); // Write the .bat file

    $getAdminVBS = <<<>>>
        Set UAC = CreateObject("Shell.Application")
        UAC.ShellExecute "%COMSPEC%", "/k ""$batFile""", "", "runas", 1
>>>;

    writefile($getAdminVBSFile, trim($getAdminVBS));
    run """cscript"" ""$getAdminVBSFile""", , 0, 0;
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1126
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: reset ntfs partition permissions

Post by yusef88 »

sorry to tell you it failed to unlock inaccessible file in win7 but Take ownership can
http://www.askvg.com/add-take-ownership ... ows-vista/

Post Reply