PS2EXE v0.2.0.0: Improvements: Platform switch (x64 or x86 or AnyCPU), new “EXE.config” file for “supported runtime”

(Original article: https://blog.kenaro.com/2011/06/21/ps2exe-tool-for-converting-powershell-scripts-to-standalone-exe-files/)

I have implemented some new switches for PS2EXE:

-x86

This compiles the EXE to be run as 32 bit application also on 64 bit OS.

-x64

This compiles the EXE to be run as 64 bit application. Therefore an 64 bit OS ist necessary.

-runtime20

This creates an “.exe.config” file with this content:

<configuration>
   <startup>
      <supportedRuntime version="v2.0.50727"/>
   </startup>
</configuration>

Please read this article on MSDN http://msdn.microsoft.com/en-us/library/w4atty68.aspx

this may fix some errors that users reported to me.

 

You can download the new version ouf PS2EXE here:

http://ps2exe.codeplex.com

10 thoughts on “PS2EXE v0.2.0.0: Improvements: Platform switch (x64 or x86 or AnyCPU), new “EXE.config” file for “supported runtime”

  1. Hello,

    Thank you so much for creating this script. I will use this religiously! I have one question though. I’ve created a script using .NET forms. I ran ps2exe against it and it worked but when my script launches, it always launches a console window with it. Is there a way to hide this console window and just display the form in the script I created?

  2. This works but I’m trying not to put this into a batch file. The script I created is a very simple GUI we’re wanting to place on all users’ desktops. I would prefer no console window to pop up at all with no switch if that’s possible.

  3. Thanx for the script, its simply awsome. I am having trouble where if you create PS script with param to take multiple parameters and converting it to exe, the converted exe didnt accepts the parameters correctly. Is there a way to fix it ?

    • Hi. I have the same situation. No parameters allowed, neither Param() or $args[]. Please help. Thanks in advance

  4. the -noconsole parameter seems to be ignored. i’ve made my exe and very pleased to have that functionality. a black console window shows for a second on executing the program and it would now be nice to avoid that. i’m using PS2EXE v0.2.0.0. please give detailed info about -noconsole

  5. Finally I could pass parameters using $args[] array. But $args[] is no global, at least when I convert PS1 to EXE. So I assign parameters from $args[] to variables in the main routine and then pass it to the functions. I could’nt pass $args as parameter to functions, maybe to my inexperience en PS

  6. Hi Thanks for the valuable tool but on windows 11 I got the following error “You are using PowerShell 4.0 or above.”

  7. This works great, but I have a couple of things to ask –

    1) I am using the script location command $PSScriptRoot, which works fine with .ps1, but when the script is converted to exe, this command is totally ignored and doesn’t produce any output. Can you please suggest how to use this?

    2) My second query is regarding converting back the EXE to Ps1, is that possible?
    Reason for asking this query is, if I converted the Ps1 to EXE, then can I be sure that the code can stay safe and can’t be converted back to readable Ps1?

    • Hi Paresh!

      Thank you for your comment!

      1) $PSScriptRoot cannot be used. This variable is set by the PowerShell runtime. But there is no “script file” after “conversation” to EXE. You need to find another way. E.g. you could try `Split-Path ([system.diagnostics.process]::GetCurrentProcess().Path)` This should work inside the EXE.

      2) It is possible, because the script is included in the EXE-File. Try to decompile the EXE file using ildasm.

      Regards
      Ingo

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.