Can not remove folder in program files directory. Changing permissions doesn't work

0

I was installing CoDeSys. I downloaded the installer executable file, which seems to be a MSI installer. Followed the steps in the installer window, and at the very last step a progress bar is shown. The bar got filled to the end, and remained full. The installer remained in this state for an hour with the progress at 100%.

There was no message shown or something else like the installer wizard that closes. I waited and then opened the installed program CoDeSys, and it worked all as it should be.

Then I closed the installer window and confirmed to stop. This was stupid because the wizard started to rollback all changes and started to remove the application...

Now when I retry running the installer wizard, it says the folder CODESYS 3.5.15.20 in Program Files should be empty. But it isn't. It still contains some remnants of the previous installation that was undone. I don't see CoDeSys in my list of installed programs, so I cannot remove it from there since it is actually already removed as I said. When I just go to my program files folder, and manually remove the CODESYS 3.5.15.20 folder from there, I always get a message saying the folder can not be removed/changed because I need permission from SYSTEM.

Tried several solutions from the internet, like changing the owner/permissions of the folder. But even when I am the owner (and not system or something else), I get no control over the folder. Changing the owner of the folder to myself ('Sam'), and retrying to delete it, displays the message: I need permission from 'Sam'.

  • My operating system is Windows 10.
  • I don't see any uninstall executable in the files stayed behind.

user2190492

Posted 2019-11-27T19:51:53.573

Reputation: 123

1“I always get a message saying the folder can not be removed/changed because I need permission from SYSTEM.” - As the built-in Administrator account change the ACL for that single folder then delete it. – Ramhound – 2019-11-27T19:54:57.787

1It still contains some remnants of the previous installation that was undone. - You may be able to delete these elements manually from the folder without removing the folder itself. – Anaksunaman – 2019-11-27T20:42:19.763

@Anaksunaman I already tried this to make the folder empty. But doesn't work. I didn't mention this in my question. – user2190492 – 2019-11-28T21:33:06.763

Answers

3

You could try using cmd as administrator.

Use the command rmdir /s /q C:/Program Files/CODESYS 3.5.15.20, assuming that's the correct file path.

DrZoo

Posted 2019-11-27T19:51:53.573

Reputation: 8 101

0

One option to attempt a removal or rename of a file or directory is to use the Pending File Rename Operating (PFRO) functionality of Windows. This will perform the action:

  • At the next restart.
  • As the local system user.
  • Early at system start to minimize a process holding a handle to the item.

To do so, you can manually create or update the REG_MULTI_SZ PendingFileRenameOperations registry value under the registry key HKLM\System\CurrentControlSet\Control\Session Manager to be read by the Windows Session Manager (SMSS.exe) at start-up. The easiest way is to use a tool to create or append to the value if it already exists.

One option is movefile.exe from Sysinternals/Microsoft.

As an example, to remove the folder C:\testdelete on the next system restart, run in an elevated prompt: movefile.exe "C:\testdelete" ""

The above command will create or append to, the REG_MULTI_SZ PendingFileRenameOperations registry value under HKLM\SYSTEM\CurrentControlSet\Control\Session Manager as shown below:

PFRO key example

Note: The entries in the value are processed in pairs such that a blank line following an item will instruct the SMSS.exe process to delete the previous item. If the proceeding line has a path then it will be renamed.

If there are issues removing the directory or any of the operations carried out, they will be logged to C:\windows\pfro.log

HelpingHand

Posted 2019-11-27T19:51:53.573

Reputation: 1 435