Skip to content

Instantly share code, notes, and snippets.

@TTimo
Created January 22, 2017 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TTimo/c221a1cae22a78370918f39e9d828d39 to your computer and use it in GitHub Desktop.
Save TTimo/c221a1cae22a78370918f39e9d828d39 to your computer and use it in GitHub Desktop.
# NOTE: This rewrites the entry every time
logging.info( 'Associate build in the registry...' )
engine_path = os.path.abspath( os.path.join( os.getcwd(), LOCAL_FOLDER ) )
engine_path_normed = os.path.normcase( os.path.normpath( engine_path ) )
logging.info( engine_path )
# open or create
key = _winreg.CreateKeyEx( _winreg.HKEY_CURRENT_USER, r"Software\Epic Games\Unreal Engine\Builds", 0, _winreg.KEY_ALL_ACCESS )
i = 0
while ( True ):
try:
( name, value, value_type ) = _winreg.EnumValue( key, i )
except WindowsError:
break
logging.info( pprint.pformat( ( name, value, value_type ) ) )
# 'samefile' is not available on Windows
if ( os.path.normcase( os.path.normpath( value ) ) == engine_path_normed ):
logging.info( 'Delete entry %s' % name )
_winreg.DeleteValue( key, name )
else:
i += 1
logging.info( 'Link the build in the registry' )
_winreg.SetValueEx( key, BUILD_GUID, 0, 1, engine_path )
_winreg.CloseKey( key )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment