Edit MSI Package
Hi everyone!
There is a task, edit the MSI Package of puppet-agent. In short, I need to do the following: get the name of the computer and add this value in lower case to .ini file during installation, in addition, I need to add any random number or, for example, a mac address to it in order to get a unique value and finally add to the end or beginning of this value static element (for example: "static"). I'll explain in more detail, I want to get a value like this: static_pcname_83712 or static_pcname_00:0a:95:9d:68:16
I will be grateful for any help
Answers (2)
Unless the MSI package itself offers a flag to accomplish this or you have access to the source, then you won't be able to modify the MSI package.
However, after installation, you could create a script that edits the .ini file that's created. In that ini file, is there something like a variable such as: UniqueID=SomeValue and you are looking to create that string?
To create a script to do this (using standard Windows scripting, nothing fancy), create a UniqueValue.cmd file and put this in the file:
for /f "usebackq tokens=3 delims=," %%a in (`getmac /fo csv /v ^| find "Ethernet"`) do set MAC=%%~aecho static_%COMPUTERNAME%_%MAC%
Note that you will need to change "Ethernet" to whatever your interface names are. If you're fortunate enough to not have whatever the variable is set in the .ini file already, you could do this (presuming the variable is UniqueID):
for /f "usebackq tokens=3 delims=," %%a in (`getmac /fo csv /v ^| find "Ethernet"`) do set MAC=%%~a
echo UniqueID=static_%COMPUTERNAME%_%MAC% >> C:\Path\To\File.ini
This will append that line to the file. If for some reason it tries to put the UniqueID on the same line, just add echo. >> C:\Path\To\File.ini above the echo command listed in the code box above:
for /f "usebackq tokens=3 delims=," %%a in (`getmac /fo csv /v ^| find "Ethernet"`) do set MAC=%%~aecho. >> C:\Path\To\File.ini
echo UniqueID=static_%COMPUTERNAME%_%MAC% >> C:\Path\To\File.ini
I solved this problem, so if my experience would be useful to someone, I did the following: 1) I wrote a script of similar content as RyanTech advised me. 2) I converted this script into an .exe file 3) Using Orca and Master Packager I added a custom action to the msi package, in the execution sequence table I made sure that the program will be executed immediately after the installer writes the parameters to the .ini file. I spent a lot of time, but it worked!
Comments:
-
If the INI file is created using the IniFile table, then you could have just edited or added the information to that table, saving you the effort of writing any custom actions. That also has the advantage of removing the entry when uninstalling. You can use property values in the INIFile table too. - EdT 4 years ago
-
Yes, of course, but you cannot do any processing in this way, as in my case, getting the name of the computer and transliterating it into lower case, the whole problem was in this. And the rest of the values (static for different computers on which you plan to install the package) I did exactly as you are described - Sick_013 4 years ago