Convert a PowerShell script to exe Including an Exe file into it - powershell

I have a few Powershell scripts that I use to copy files and run installations with the required install steps included in the sript, i know how to convert these scripts into exes. I would like to know, how to include the files I am installing with the script in the powershell converted exe?

This utility on github has proven very useful to me:
https://github.com/rzander/PS2EXE
It comes with a pretty straightforward GUI and command-line version, but only works with one PowerShell file.
I have modified a personal version to take multiple files and combine them into one executable. Let me know if you’re interested and I can upload it.

I would like to answer my own question for whom ever come across the same issue or need!
I had the way of doing this all along, but I didn't pay attention to details: For what I required which is to convert a .PS1 script that installs postgresql unattended, to an .exe file including(Postgres enbedded in the exe).
The best tool for this is the "PS1 to EXE" https://gallery.technet.microsoft.com/PS1-To-EXE-Generator-d39e8be2 software,
1. Load your ps1 file, make sure everything is working before hand.
2. Embed the the files you need for the ps1 to work (embed option is on the right column next to the "Options")
Then you can click the convert option
PS: Be sure to have the correct file path.

Related

Can my PowerGUI compiled PowerShell script be viewed by users?

I use PowerGUI to convert my PowerShell scripts to executables, and it is working fine.
I'd like to prevent my compiled script from being extracted or decompiled by users I distribute the generated executable to.
Is it possible to view my PowerShell script inside the generated executable? If so, how do I prevent this?
Unfortunately with PowerGUI it's not possible to prevent users of your executable from viewing your script, even if you use the "Protect script source code with a password" option.
The executable that PowerGUI generates is a self extracting ZIP file so it's possible to use 7-zip or WinRAR to open this file and view the original PowerShell script.
If you set a password using the "Protect script source code with a password" option all this does is password protect the files inside the ZIP container. However when launching the generated executable you'll be prompted for said password which can then be used to access the original script.
If you want to somewhat obfuscate the code, look at PS2EXE:
http://ps2exe.codeplex.com/
which points to:
https://gallery.technet.microsoft.com/PS2EXE-Convert-PowerShell-9e4e07f1
download the ps2exe
http://ps2exe.codeplex.com/
run power shell
cd the folder of ps2exe
run:
.\yourfile.ps1 -inputFile C:\Users\franc\Desktop\temp\ps2exe\Install.ps1 C:\Users\franc\Desktop\temp\ps2exe\Install.exe
check the folder, the exe will be there

How do we include a batch file in a msi installer which should run every time the msi is installed?

Wow do we include a batch file in a msi installer which should run every time the msi is installed?
I'm not sure but it might work if you create a custom action to execute cmd.exe and have the path and name of the batch file as a parameter.
Otherwise you can create a custom action that contains a vbscript file that executes the .bat file (or possibly you can use a vbscript instead of a bat file).
Just be aware that I've heard that some antivirus programs can get a bit nervous if you include scripts in your msi and might make the install fail.

link a batch scrript (.bat file) to a different console/shell on Windows XP?

Is there any way to link batch script (.bat files) so that they run via another shell/console and not cmd.exe ?
For instance, if one install powershell or others (a few are open-source projects are available on soureceforge), how to link it to your bat files ?
I looked in the "file types" menu but it seems that the bat extensions is not listed !!
Cheers
David
You can probably always set another association in the registry under HKCR. But I don't particularly see the point. PowerShell won't execute batch files anyway; it's a completely different language.

How to execute a command from with in MSI?

I have a installation setup with works like this: /exec.exe /some-command
This whole setup is located on a shared disk to which my target machine have access to. All i want is to create a small MSI wrapper that basically executes the above command. I don't need to any other fancy things?
I looked up on the web; there are tools that create MSI for you but they generate huge amount of other things with them as well.
My need is very simple and straight forward. It would be great if some could help me with this issue.
Thanks,
Omer
With WiX it is very simple to create a MSI-Wrapper that just executes a custom action firing up a command line.
MSI seems like the wrong tool for the job in this instance. A big reason that MSI's are popular, is because they allow for easy install/uninstall in one package (among many other things).
I'd suggest using a simple batch (or vbscript, or perl script, or whatever) wrapped up in a self-extracting executable. This way you can include custom logic, all without the overhead of the MSI. Besides, you aren't using any of the functionality of an MSI --- except that it wraps up files into a single file.
You can use a pay program such as WinZip Self-Extractor, or you can use 7-zip (free) and a GUI app someone has written to create self-extracting EXE's: 7-ZIP SFX MAKER
I've used 7-zip sfx maker before, and I can vouch that it works very well.

Making installation files

I need to make installation file (.exe), but is that possible with batch script and how?
I made installation with some software (Deployment...) but I need to do that with script. I have all necessary files for my installation.
Is that possible?
Marko
Virtually every tool for building installation packages provides ability to include arbitrary sripts to the installation process. Just inspect your tool for this capability...
Here, we often include sripts in our WIX installations. Of course, user expirience is better when you building installation package nativelly, but in some cases this is acceptable practice (mostly when there is no non-tech users planned).
With a batch script, you will not be able to make a .exe (unless you call a .exe creator from within the batch script!). Why not try Inno Setup or NSIS? ISTool helps in creating Inno Setup scripts with ease and speed.
You can't make an .exe using nothing but a batch script. You can however use a batch script to create the installation specification file(s) and then run that file through an installer creator program like the ones mentioned in the other answers here. Perhaps you could be a bit clearer about what you actually need to do?