Python can't open a file in C:\Windows\System32\oobe\Info\backgrounds

pygame, python, windows

Solution

Found the solution! As according to this article, I replaced /System32/ with /Sysnative/ and all was well.

Problem

Windows 7 x64, Python 2.7. Trying to make a script to automatically change the logon background. I'm using pygame, an SDL wrapper for python, but the code should be self-explanatory: ``` import pygame import os image = pygame.image.load(os.path.normpath("C:/Users/nivekuil/Desktop/backgroundDefault.jpg")) surface = pygame.Surface((1366,768)) surface.fill((255,255,255)) surface.blit(image, (0,0)) surface = pygame.image.save(surface, os.path.normpath("C:/Windows/System32/oobe/Info/backgrounds/backgroundDefault.jpg")) ``` Returns the error: ``` Traceback (most recent call last): File "C:/Users/nivekuil/Documents/background.py", line 8, in <module> surface = pygame.image.save(surface, os.path.normpath("C:/Windows/System32/oobe/Info/backgrounds/backgroundDefault.jpg")) error: SaveJPEG: could not open C:\Windows\System32\oobe\Info\backgrounds\backgroundDefault.jpg ``` I don't think this is a problem with pygame, as it works fine if I save it to somewhere like Desktop. I'm also running IDLE as an administrator, and I've also run the program as a task in Task Scheduler with "Run with highest privileges" checked.

Original source