none
Corrupted Windows Registry With Recursive File Deletion RRS feed

  • Question

  • I was writing a python script to automatically sort files and part of my program did an automatic file tree deletion within my project. The project existed entirely within a set of "safe" testing directories and I wasn't trying to edit any OS specific files. The problematic code was similar to the following:

    import shutil
    
    shutil.rmtree('Path/To/Test/Directory', ignore_errors = True)
    


    I had performed similar operations before, but this time my program froze. After restarting Windows I noticed that no apps would show up properly when I typed them in the search bar, and then after attempting to open chrome from the desktop, I discovered that most apps, with the exception of file explorer and cmd.exe, would not open at all. The error messages are similar to the following:

    The application has failed to start because its side-by side
    configuration is incorrect. Please see the application event
    log or use the command-line sxstrace.exe tool for more detail.
     

    I appear to have somehow corrupted my registry unintentionally.

    Could someone please enlighten me: as to how this may have occurred; if there is a solution simpler than factory resetting  my bricked machine; and how to avoid something like this in the future.

    Thanks in advance for the feedback.

    Thursday, March 5, 2020 2:24 PM

All replies

  • I suspect that it wasn't your program that caused the problem - more just a chance that you were running it when something else happened that resulted in your current situation.

    I'd try checking the disk, memory, and if they test out ok, repair your OS installation.

    Thursday, March 5, 2020 3:50 PM
  • Hi,

    Thanks for posting here.

    First, shutil.rmtree is not in the support scope of this fourm. Maybe you could open an issue for this api on the python sites. And the api was here:

    https://github.com/python/cpython/blob/master/Lib/shutil.py#L679

    In addition, I have found following notes on python doc:

    On platforms that support the necessary fd-based functions a symlink attack resistant version of rmtree() is used by default. On other platforms, the rmtree() implementation is susceptible to a symlink attack: given proper timing and circumstances, attackers can manipulate symlinks on the filesystem to delete files they wouldn’t be able to access otherwise. Applications can use the rmtree.avoids_symlink_attacks function attribute to determine which case applies.

    Did you pass a symlink?

    I will off-topic this thread later, thanks for understanding.

    Best Regards,

    Drake


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 6, 2020 3:24 AM