Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyInstaller set process description

Is there a way to compile Python script with given process description? For example, I have file named 'main.py' and after compilation I have 'main.exe'. When I run my script it shows 'main' in Task Manager but I want something like 'My python script'. Is it possible with PyInstaller?

like image 725
kacpo1 Avatar asked Sep 01 '25 10:09

kacpo1


1 Answers

Sure, it is possible. What you have to do is (see here for the doc):

  1. Grab an exe file that include the metadata categories that you want for your exe
  2. Run the pyinstaller tool in a command prompt: pyi-grab_version C:\path\to\that\file.exe
  3. Edit the file file_version_info.txt obtained from step 2
  4. Run pyinstaller --version-file=file_version_info.txt main.py

Step 4 can be replaced by this if you build your exe using a pyinstaller spec file:

  1. Add version='file_version_info.txt' in your main.spec file:
    exe = EXE(...
              ...
              version='file_version_info.txt'
              )
    
    and run pyinstaller main.spec.

Example

In your case, the metadata category that you want to edit in file_version_info.txt is FileDescription. See below an example of a file_version_info.txt file:

# 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=(1, 2, 3, 0),
    prodvers=(1, 2, 3, 0),
    # Contains a bitmask that specifies the valid bits 'flags'r
    mask=0x3f,
    # Contains a bitmask that specifies the Boolean attributes of the file.
    flags=0x0,
    # The operating system for which this file was designed.
    # 0x4 - NT and there is no need to change it.
    OS=0x40004,
    # The general type of file.
    # 0x1 - the file is an application.
    fileType=0x1,
    # The function of the file.
    # 0x0 - the function is not defined for this fileType
    subtype=0x0,
    # Creation date and time stamp.
    date=(0, 0)
    ),
  kids=[
    StringFileInfo(
      [
      StringTable(
        u'040904b0',
        [StringStruct(u'CompanyName', u'MyCompany'),
        StringStruct(u'FileDescription', u'MyApp'),
        StringStruct(u'FileVersion', u'1.23.0'),
        StringStruct(u'InternalName', u'cardprocess'),
        StringStruct(u'LegalCopyright', u'No Copyright © 2020'),
        StringStruct(u'OriginalFilename', u'myapp.exe'),
        StringStruct(u'ProductName', u'myapp'),
        StringStruct(u'ProductVersion', u'1.23.0')])
      ]), 
    VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
  ]
)

like image 122
maxhaz Avatar answered Sep 02 '25 22:09

maxhaz