improve uninstalling apps to show errors and exit if taking ownership fails #51
This commit is contained in:
@@ -4150,8 +4150,8 @@ functions:
|
||||
$directories = @($package.InstallLocation, \"$env:LOCALAPPDATA\Packages\$($package.PackageFamilyName)\");
|
||||
foreach($dir in $directories) {
|
||||
if ( !$dir -Or !(Test-Path \"$dir\") ) { continue; }
|
||||
cmd /c takeown /f \"$dir\" /r /d y | Out-Null;
|
||||
cmd /c icacls \"$dir\" /grant administrators:F /t | Out-Null;
|
||||
cmd /c ('takeown /f \"' + $dir + '\" /r /d y 1> nul'); if($LASTEXITCODE) { throw 'Failed to take ownership'; }
|
||||
cmd /c ('icacls \"' + $dir + '\" /grant administrators:F /t 1> nul'); if($LASTEXITCODE) { throw 'Failed to take ownership'; }
|
||||
$files = Get-ChildItem -File -Path $dir -Recurse -Force;
|
||||
foreach($file in $files) {
|
||||
if($file.Name.EndsWith('.OLD')) { continue; }
|
||||
@@ -4169,8 +4169,8 @@ functions:
|
||||
$directories = @($package.InstallLocation, \"$env:LOCALAPPDATA\Packages\$($package.PackageFamilyName)\");
|
||||
foreach($dir in $directories) {
|
||||
if ( !$dir -Or !(Test-Path \"$dir\") ) { continue; }
|
||||
cmd /c takeown /f \"$dir\" /r /d y | Out-Null;
|
||||
cmd /c icacls \"$dir\" /grant administrators:F /t | Out-Null;
|
||||
cmd /c ('takeown /f \"' + $dir + '\" /r /d y 1> nul'); if($LASTEXITCODE) { throw 'Failed to take ownership'; }
|
||||
cmd /c ('icacls \"' + $dir + '\" /grant administrators:F /t 1> nul'); if($LASTEXITCODE) { throw 'Failed to take ownership'; }
|
||||
$files = Get-ChildItem -File -Path \"$dir\*.OLD\" -Recurse -Force;
|
||||
foreach($file in $files) {
|
||||
$newName = $file.FullName.Substring(0, $file.FullName.Length - 4);
|
||||
|
||||
Reference in New Issue
Block a user