Is there a python command to package all the files in an existing .blend without it being opened?
You can do it using Blender in the GUI-less mode:


create a new Python script like this one (I'll call it pack_GUIless.py):

import bpy

bpy.ops.file.pack_all()
open the Command Prompt (Windows) or Terminal (Linux) and run the command blender --b [path_to_file]/test_file.blend -P [path_to_script]/pack_GUIless.py. You might have to put the blender path as well if you have a portable version of Blender. More info here:https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html


This will open blender in the terminal and close it as soon as the files of the test_file.blend project are packed, so it will be fast and clean (no GUI loaded).
If you need to do it do it many times you might want to create a .cmd script to make it easier, like this one I made for rendering purposes (so you edit the script with the path to the .blend file and run it, and it will do everything by himself).

Please mind that I didn't test this specific case, so you might have to tweak something