Answer the question
In order to leave comments, you need to log in
Is it possible to compile a Powershell script into an executable including the DLLs used?
Good afternoon, there is a Powershell script that uses additional DLL libraries via
[System.Reflection.Assembly]::LoadFrom("С:\temp\сustom_one.dll")
[System.Reflection.Assembly]::LoadFrom("С:\temp\сustom_two.dll")
Answer the question
In order to leave comments, you need to log in
here they do something similar:
https://www.loginvsi.com/blog/565-embed-external-f...
Write a small Go program, for example. Using a library like https://github.com/rakyll/statik , add the necessary dlls and the powershell script itself into the binary. The Go binary will copy the dlls and the script to a temporary folder on the first run, and then run the powershell script. On next runs, the Go binary will simply run the script. Additionally, you can add a comparison of the hashes of the embedded and existing files in order to replace obsolete files (dlls and script) when a new version is released.
Alternative: if the powershell script is really simple (insert a record into the database) and dlls are used to communicate with the database or some other standard logic, just rewrite it in Go without any dlls and runtime dependencies.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question