Is it possible to embed powershell into a .net executable that can run a specified powershell script? It sounds silly when I ask, but here is the scenerio: We have a few applications that run on workstations and unattended on servers that are constantly
changing their configuration. They have in-house and 3rd party plugin .dlls that change on a regular basis. I need the application to update itself and configure itself automatically EVERY time it starts. There is a central configuration and code repository
that has the instructions on how to update and what registry, ini, conf, etc to change. And they are all different slightly depending on the user and machine.
Since these applications don't provide an auto-updating feature, we resorted replacing the .exe with our own that runs a script of limited functionality, pulls the updates configures, and then runs the original .exe which was renamed. This seems to work pretty
well and is the only way to update the .dlls that may be locked by a running app. The updater.exe has a companion text file. This text file has the sequence of commands so the updater.exe doesn't need to change to create a new configuration.
The reason this system needs replacing is maintaining the updater.exe to do all the things it needs to is costly and only the person who wrote it knows how to do it.
So back to the question. Can I package powershell into a .exe so that it can replace our c++ updater?
Bonus question: Anyone figure out how to intercept the CreateProcess call on the application so I don't have to do all this nonsense? I almost got it working with "image file execution options" but then I either get an infinate loop, or the debugging flag is
set to true, which breaks certain apps licensing systems, or they perform slower.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.