Thursday, May 22, 2014

#11 : Creating executable (EXE) from Powershell script using PS2EXE?

As you all know that Powershell is .NET Framework based scripting language. When a Powershell script runs, scripting is converted ty MSIL (Microsoft Intermediate Langage) and then executed. In short we can say that Powershell script is not interpreted as Batch programming or Unix-based shell scripting. So, internally a Powershell script is converted to machine language then why there is no in-build compiler for Powershell? This is puzzle to me, but this is how it is. Anyways, when we are talking about scripting language, why to think about compiling script to EXE, if you really want to compile, use C# or VB.NET. But you know what, we always think something which is missing. Overall, there is no executable compilation mechanism provided in Powershell (Period!).

There are some alternatives to compile script to Powershell. One of the tool is PS2EXE. This can be download from CodePlex from below location:

https://gallery.technet.microsoft.com/PS2EXE-Convert-PowerShell-9e4e07f1

This is good utility which creates exe from a ps1 file. Before you get so excited to use it, let me tell you some facts about it:
1. This utility will only encapsulate your script and create exe with that. This is not a compilation of your script. So, you still need to have Powershell installed on the machine where you run.

2. You code is safe and embedded, so nobody can read what you are doing.

You can try it if this meets your requirement. Next time, we will talk about another tool similar to this.

Thank you for reading this article!

No comments:

Post a Comment

#112: How to handle xml document in Powershell?

 In PowerShell, you can handle XML data using various cmdlets and methods provided by the .NET Framework. Here's a basic guide on how to...