0

I am trying to os.chdir() into system32 from python on windows, but when i attempt to change into this directory I am getting this error:

FileNotFoundError: [WinError 2] The system cannot find the file specified: 
'/System32/

So obviously Python can't see this directory but I don't know why because os.listdir() shows this directory in the list. Does this have to do with the permissions that python has? Ultimately my goal is to change into the winevt directory to pull and dump the log files and to check for any errors, so any way to grab these is completely fine. My intuition was simply to change into the directory, open and read the log files and then check for errors, then print and report those errors.

3 Answers 3

3

Your current working directory may be different from the one where folder is.

Use this to check your current working directory before changing the directory.

 print('Present DIR is : ',os.getcwd())

Then go to the correct directory and change the directory.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi thanks for the response. I am able to move to other directories. But I can't enter system32. The reason for this, I believe is actually because my Python is installed and running as 32 bit.
Yes, you must be having a 64 bit OS and you a 32 bit version so it looks into the incorrect directory.
stackoverflow.com/questions/41630224/… use this link as this may help you handle the 32 bit 64 bit issue.
0

When you try to get into System32, use absolute path rather than the relative path, with the following:

os.chdir(r'C:/Windows/System32')

or in your case:

os.chdir(r'C:\Windows\System32\winevt\Logs')

As Archit said, you might not be in the correct directory.

Comments

0

The solution to this problem was a little bit hard to come by. I first tried uninstalling python 32 bit but that just broke everything.

I eventually installed python36 and added the python36.dll and the location of this dll to the user and system path (on Windows). Then I made sure to remove anything in the path involving python 34 or python36-32 which is the 32 bit version of python. This then allowed my to easily os.chdir into system32

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.