Reputation: 584
I'm developing some scripts that I later pack into EXE using PS2EXE to ship to end user. The key point here is that they only know how to double click executable and they want to do just that. The script then builds simple GUI using WPF where end user can click buttons and check boxes and do whatever they need to do. Now, as I have several similar scripts and total volume of code grows bigger, I would like to reuse some of it packing various functions into modules and just use Import-Module in my script - standard practice.
However, I realized, that when I use PS2EXE in this case, it does not pack modules in the EXE file. It still works but it requires model to be deployed on the user's machine. Which immediately makes it over-complicated for the end user. My question - is there a way to develop script re-using code through modules and still pack it into EXE files (along with all the imported modules) for end users, so that the single EXE file is everything they need?
Upvotes: 1
Views: 645
Reputation: 1423
Set command in the EXE file that you want to reuse that return the required function declaration statements.
other scripts that want to use these functions, obtaining these statements by executing the command,and execute them through Invoke-Expression Cmdlet.
Upvotes: -1