Rahul Mallick
Rahul Mallick

Reputation: 89

What will happen on executing os.rmdir("C:\Windows\System32") in python?

I came across this function . I want to know if it is possible to actually remove the operating system if it's already running . If it is , then what would be the steps that follow once it starts executing ?
os.rmdir("C:\Windows\System32")

Upvotes: 0

Views: 2675

Answers (2)

New Dev
New Dev

Reputation: 23

It would not work, you'd get a permission error. Even if you run the script as administrator, many if not all of the files in System32 are protected by TrustedInstaller

Upvotes: 0

user16989126
user16989126

Reputation:

First, the directory is not empty, so os.rmdir() will fail.

Second, you would have to at least run the python program as administrator, because the System32 folder is protected.

And finally, if you did manage to delete System32 it would eventually delete the process that is deleting files, and stop. Although by then the system will be critically damaged.

Upvotes: 2

Related Questions