Git Product home page Git Product logo

create-exefromps1's Introduction

Create-EXEFromPS1

Takes one PowerShell script and any number of supplementary files or even a directory and creates an exe using Windows's built in iexpress program. The exe will run on any machine with PowerShell 2.0+.

Portable Script

If you don't want to mess with the module, you can simply use the Create-EXEFrom.ps1 script. For details on advanced parameters, reference below.

Module

Copy the repo into your modules directory (C:\Users<username>\Documents\WindowsPowerShell\Modules) and then you will be able to import by typing Import-Module Create-EXEFromPS1 in PowerShell. If you wish for the module to be automatically imported you can enter Add-Content $profile 'Import-Module Create-EXEFromPS1' in PowerShell. The command can be run with New-EXEFromPS1.

Running

To simply turn one ps1 into an exe, run with no parameters and you will be prompted to select the file from a file browser. For details on advanced parameters, reference below.

By default, if your scripts reference relative paths or you use $PSScriptRoot, the temporary directory that the exe's contents were extracted to will be used. To use the directory that the exe is run from, use $(Split-Path -Parent $args[0]).

Parameters

PSScriptPath - Path string to PowerShell script that you want to use as the first thing iexpress calls when the exe is run. If blank, you will be prompted with a file browse dialog where you can select a file.

SupplementalFilePaths - Array of comma separated supplemental file paths that you want to include as resources.

SelectSupplementalFiles - Use this flag to be prompted to select the supplementary files in an Open File Dialog.

SupplementalDirectoryPath - Path to a directory that will be zipped and added as a supplementary file. When the exe is run, this script will first be unzipped and all files are available.

SelectSupplementalDirectory - Use this flag to be prompted to select a directory in an Open File Dialog that will be zipped and added as a supplementary file. When the exe is run, this script will first be unzipped and all files are available.

KeepTempDir - Keep the temp directory around after the exe is created. It is available at the root of C:.

x86 - Use the 32-bit iexpress path so that 32-bit PowerShell is consequently called. Intended for compatibility with older devices.

SigningCertificate - Sign all PowerShell scripts and subsequent executable with the defined certificate. Expected format of Cert:\CurrentUser\My\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

OutputDirectory - Move the completed executable to the defined directory.

Examples

New-EXEFromPS1 -PSScriptPath .\test.ps1 -SupplementalFilePaths '..\test2.ps1', .\ps1toexe.ps1
# Creates an exe using the provided PowerShell script and supplemental files.

New-EXEFromPS1 -SelectSupplementalFiles
Prompts the user to select the PowerShell script and supplemental files using an Open File Dialog.

New-EXEFromPS1 -SupplementalDirectoryPath 'C:\Temp\MyTestDir' -KeepTempDir
# Zips MyTestDir and attaches it to the exe. When the exe is run, but before the user's script gets run, 
# it will be extracted to the same directory as the user's script. Temp directory used during exe creation
# will be left intact for user inspection or debugging purposes.

New-EXEFromPS1 -SelectSupplementalFiles -x86 -SigningCertificate Cert:\CurrentUser\My\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -OutputDirectory $env:userprofile\Desktop
# Prompts the user to select the PowerShell script and supplemental files using an Open File Dialog. Creates a 32-bit application using the 32-bit iexpress binary.
# If the defined script or supplemental files are PowerShell scripts they will be signed with the defined certificate. Once the executable is generated it will also
# be signed and moved to the specified output directory.

Issues

None that I'm aware of, but please let me know if you find any!

create-exefromps1's People

Contributors

etcha-sketch avatar nickrod518 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

create-exefromps1's Issues

Unable to access $args

Just was to preface by saying this is the only PS to EXE tool I've found that will bundle the modules with it, and it works really well!

I'm trying to run a PS script that creates log files inside a directory that should be placed next to the .exe file. As per the README.md I'm trying to access the $args variable to get the file path but they are null.
Any ideas?
Thanks

How to pass parameters to embedded PowerShell Script

Hello,

maybe i've overseen something. I created an EXE file from a PS Script and an additional folder.
In the next step i want to run the EXE file silent with an additional parameter or named parameter. That did not work for me.

What i already tried:

That starts the installer and extracts the content to C:\temp. Afterwards the ps script is started and asks for the parameter
install.exe /t:c:\temp

install.exe /t:c:\temp install (unnamed parameter for PS Script)
install.exe /t:c:\temp -action (named parameter for PS Script)

Is it not possible to run the exe with additional parameter?

Thank you for coming back to me.

Greetings Michael

Custom Icon Support

iexpress does not support custom icons but if there is a way to replace an exe's icon with PowerShell after the exe has been generated, I will implement it into this project.

Powershell script not found

Ive packaged my ps1 and a supp folder but when the post install cmd runs powershell complains it cant find the ps1 scipt in the correct temp folder. @nickrod518

I can't modify a registry key

Hi, my powershell script modify some registry keys, it works fine when the .ps1 is lunched as a powershell script, but don't works when lunched in the .exe file .

Unable to reach USMT binaries - Windows 10 issue

No saved state found at [C:\TEMP\MigrationStore].
Unable to reach USMT binaries. Verify [C:\Users\xxx\AppData\Local\Temp\IXP000.TMP\USMT\amd64] exists and restart script.

It's not copying/creating the USMT folder in the temp folder

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.