background preloader

Blogs

Facebook Twitter

Make-PS1ExeWrapper | Keith Hill's Blog. Occasionally folks want to be able to create an EXE from PoweShell. PowerShell can’t do this by itself but this can be done with PowerShell script. Essentially what you can do is create a simple console EXE program that embeds the script as a resource and the EXE, upon loading retrieves the script and throws it at a PowerShell runspace to execute.

Here’s the script for a feasibility test of doing this very thing. Note that this script depends on Write-GZip from the PowerShell Community Extensions. Updated 6-21-2011: The migration from Windows Live Spaces to WordPress seems to have messed with the formatting of the script. Updated 3-4-2012: I have added the ability to handle positional parameters passed into the EXE as well as a -NET40 switch to compile using the v4.0 C# compiler.

[Parameter(Mandatory = $true, Position = 1)] [string] $OutputAssembly, [Parameter(Position = 2)] [string] $IconPath ) Begin { Set-StrictMode -Version latest return script; } if (input ! Return results; } #endregion. PowerShell и другие скрипты. Kazun. MS Windows PowerShell - Lebedev Yuriy. Vadims Podans's blog - ShareUtils PS module. NetZ.