Search code examples
pythonpython-3.xmetadataexecutable

Edit or change a compiled python script (.exe file) details


My question is: Is there a way to easily set the details/metadata of a .exe file?

I have created a working python program that I have compiled into a .exe file using pyinstaller. When I go and right click the compiled program and go to Properties > Details it looks like this:

Script.exe

--Description-------------------
File Description
Type          Application
File Version
Product Name
Product Version
Copyright
Size          37.0 MB
Date Modified  xx/xx/2020
Language

I would like to be able to change this metadata.

It would be best if their is a way to do this so that all I have to do is add another file that automatically sets this data.

The closest thing that I have found that does this would be a Resouces.rc file that is used in projects that are made in C++ or C#.

Is there a way that I can fix this? How do you do it?


Solution

  • Solved.

    All that I had to do was create this version.txt and fill in the relevant information.

    version.txt:

    # UTF-8
    #
    # For more details about fixed file info 'ffi' see:
    # http://msdn.microsoft.com/en-us/library/ms646997.aspx
    VSVersionInfo(
      ffi=FixedFileInfo(
        # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
        # Set not needed items to zero 0.
        filevers=(x, x, x, x), #<- Put File version here
        # prodvers=(3, 0, 10, 2),
        # Contains a bitmask that specifies the valid bits 'flags'
        mask=0x3f, #<- Do not change
        # Contains a bitmask that specifies the Boolean attributes of the file.
        flags=0x0, #<- Do not change
        # The operating system for which this file was designed.
        # 0x4 - NT and there is no need to change it.
        OS=0x4, #<- Do not change
        # The general type of file.
        # 0x1 - the file is an application.
        fileType=0x1, #<- Do not change
        # The function of the file.
        # 0x0 - the function is not defined for this fileType
        subtype=0x0, #<- Do not change
        # Creation date and time stamp. Sets it automatically. Do not change.
        date=(0, 0) #<- Do not change
        ),
      kids=[ 
        StringFileInfo( 
          [ 
          StringTable(
            u'040904b0',
            [StringStruct(u'CompanyName', u'Your name here'),
            StringStruct(u'ProductName', u'name here'),
            StringStruct(u'ProductVersion', u'x.x.x.x'), #<- should be same as filevers
            StringStruct(u'OriginalFilename', u'productname.exe'),
            StringStruct(u'FileDescription', u'Short description goes here'),
            StringStruct(u'LegalCopyright', u'copyright stuff here'),
            StringStruct(u'LegalTrademarks', u'legal stuff here'),])
          ]),
        VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
      ]
    )
    

    Once that was created, I could add it to my Pyinstaller creation command with --version-file version.txt