编辑或更改编译后的Python脚本(.exe文件)详细信息

alen0pnh  于 2023-08-08  发布在  Python
关注(0)|答案(1)|浏览(124)

我的问题是:有没有一种方法可以轻松地设置.exe文件的详细信息/元数据?
我已经创建了一个工作的python程序,我已经使用pyinstaller编译成一个.exe文件。当我右键单击编译后的程序并转到Properties > Details时,它看起来像这样:
Script.exe

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

字符串
我希望能够更改此元数据。
这将是最好的,如果他们是一种方法来做到这一点,使所有我要做的是添加另一个文件,自动设置此数据。
我发现的最接近这一点的是Resouces.rc文件,它用于C++或C#的项目。
有什么办法能让我弥补吗?你是怎么做到的?

rjjhvcjd

rjjhvcjd1#

解决了
我所要做的就是创建这个version.txt并填写相关信息。
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])])
  ]
)

字符串
一旦创建了它,我就可以使用--version-file version.txt将它添加到Pyinstaller创建命令中

相关问题