W4RH4WK / Debloat-Windows-10

A Collection of Scripts Which Disable / Remove Windows 10 Features and Apps
Other
6.1k stars 844 forks source link

Failed: Force removing system apps #37

Closed tumpio closed 9 years ago

tumpio commented 9 years ago

This fails currently for me with permission denied error. And the script goes in infinite loop displaying the same error messages.

Gist of the error: https://gist.github.com/tumpio/0aa9198a07c4e187c288

Does it work for everyone else? @Carol666uk had similar problems here #36

Will this require some more "take-own" magic? :)

W4RH4WK commented 9 years ago

Did you run the script on an clean installation + all updates, or has the system been used in the meantime? It won't help much if I just end up with "well I cannot reproduce this in my clean VM".

tumpio commented 9 years ago

Well, it was installed yesterday night, so pretty clean :) The default language is not English. The take-own fails also on other script where it is used e.g fix-privacy-settings.

I'll try to find the cause, I think it might be some locale problem with names e.g. "Administrators"

tumpio commented 9 years ago

So the reason is takeown-registry fails:

PS C:\Windows\system32> Takeown-Registry("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Spynet")
Exception calling "SetOwner" with "1" argument(s): "Joidenkin tai kaikkien tunnisteviittauksien muuntaminen epäonnistui."
At E:\Devel\Debloat-Windows-10\lib\take-own.psm1:22 char:5
+     $acl.SetOwner($owner)
+     ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IdentityNotMappedException

Exception calling "SetAccessRule" with "1" argument(s): "Joidenkin tai kaikkien tunnisteviittauksien muuntaminen epäonnistui."
At E:\Devel\Debloat-Windows-10\lib\take-own.psm1:28 char:5
+     $acl.SetAccessRule($rule)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IdentityNotMappedException
W4RH4WK commented 9 years ago

Yes this can indeed be caused by having the system set to a different language. The other strings like "FullControl" and so on should still work, but "Administrators" should be changed, will look into this today. Thanks.

W4RH4WK commented 9 years ago

Can you retry with the latest version? I now use the predefined SID for referencing the Administrators group (src: KM243330). This should be the same among all languages.

tumpio commented 9 years ago

Still fails, but there is also another "Administrators" in:

$rule = New-Object System.Security.AccessControl.RegistryAccessRule("Administrators", "FullControl", "Allow")
tumpio commented 9 years ago

It works after replacing that too with $admins