As I already stated in your
other thread, I think you are doing it wrong, because you are doing some needlessly over complicated stuff that does not even work, because there is no such thing as an unstoppable process. If you would do it the other way around it would be much easier, portable, and you wouldn't run into such niche problems you are doing now.
That said, what you are trying to do will probably not work as soon as you try running it on a machine that has some antivirus installed, because this is very often used by malware (you have a program that ships the malware, and extracts it).
That you want to dynamically write things into it doesn't make it better, because this is also a common practice for malware, that they modify themselves to a. add information to the executable or b. change their checksums so they don't get detected by antivirus programs.
So it would be a miracle if you get your program running on any properly updated windows computer with an antivirus.
But lets say you are on a computer with no such protection and the OS let's you do this, then this is easy:
1. create your program you want to pack.
2. Add a pattern string as a hardcoded constant to your program, which will be used as the thing you want to change
3. Put this program into the resources of your shipping program (multiple possibilities, e.g. encode it to base64 and put it into a string constant)
4. the shipping program then extracts the program, makes a simple text search-and-replace for the pattern hardcoded in step 2 with the information you want to put in (like your path) and writes it to the filesystem.
And voila, you have a customized executable shipped with your program