PS2EXE-GUI: "Convert" PowerShell Scripts to EXE Files with GUI

Overworking of the great script of Ingo Karstein with GUI support. The GUI output and input is activated with one switch, real windows executables are generated. With Powershell 5.x support and graphical front end. Now here:
4.7 Star
37,227 times
Add to favorites
E-mail Twitter Digg Facebook
  • Can an option be added to support Mixed Mode?
    2 Posts | Last post December 23, 2017
    • I was compiling a PS script that used Exchange Management and was getting an error like below when executing the EX commands:
      mixed mode assembly is built against version 'v2.0.50727'
      I resolved it by editing the .config file to this:
      <startup useLegacyV2RuntimeActivationPolicy="true">
      If there isn't an option already that I'm overlooking, can there be a switch that automagically adds that to the config file?
      Great job overall, this project really saved my project many thanks to Markus and Ingo
    • Hello Joshuar75,
      it seems you're running the compiled script in a .Net V4 environment but referencing a .Net V2/V3.5 assembly.
      Since this situation is very special there is no switch to PS2EXE to make the necessary entry in the config file for the resulting binary. I hope that is okay for you.
  • Is there an benefit to this free online/offline converter?
    2 Posts | Last post December 15, 2017
    • Dear Markus,
      Can you pls tell me? Is there an benefit to this free online/offline converter? 
      Online converting:
      Offline converting:
      I want to be sure using the best compiler
    • Hello Christian,
      "Ps1 To Exe" from F2KO creates an self-unpacking executable that extracts the powershell script (and acompanying files) to the user's temporary directory and starts a powershell instance with the script after unpacking.
      PS2EXE creates an executable that starts a powershell runtime in memory with the script.
      You have to decide for yourself what the best compiler for your needs is.
  • Processing stderr
    3 Posts | Last post December 05, 2017
    • Create ConsoleApp5.exe By compiling this code:
      using System;
      using System.IO;
      namespace ConsoleApp5
          class Program
              static int Main()
                  TextWriter errorWriter = Console.Error;
                  return -1;
      Create test.ps1 script with this code:
      $ErrorActionPreference = "Stop"
      "Done!" | Write-Host
      Run test.ps1 from the folder where ConsoleApp5.exe resides and observe that both "bla" and "Done!" are printed out.
      Now compile test.ps1 with ps2exe and run it. Observer that no output at all is produced. 
      Now, partially, this is similar to what I'm asking in my previous post, but there is a difference. In this particular case, we have a perfectly valid ps1 script that does not produce errors. And this script is something that ps2exe does not seem to like. 
    • Hello Andrew Savinykh,
      this is a very similiar case to your other question. ConsoleApp5.exe writes to the error pipeline, the PS2EXE host interprets this as an error and stops. Because of the bug mentioned in your other question the error output is not displayed.
      I'm looking for a solution here to.
    • Hello Andrew Savinykh,
      I corrected the error of swallowing errors in the new version of PS2EXE that is available now.
      I did not find the reason why PS2EXE interprets an output to the error channel as an error while powershell.exe does not. Sorry, no fix for this in sight.
  • erroraction
    3 Posts | Last post December 05, 2017
    • Consider this script file test.ps1:
      $ErrorActionPreference = "Stop"
      If it's run from command line, a error is produced:
      bla : The term 'bla' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
      At G:\_vg\3\c.ps1:2 char:1
      + bla
      + ~~~
          + CategoryInfo          : ObjectNotFound: (bla:String) [], ParentContainsErrorRecordException
          + FullyQualifiedErrorId : CommandNotFoundException
      However, if you compile this code with ps2exe and run it, no error is shown.
      Is there a reason why? I don't think that ps2exe should silently swallow errors.
    • Hello Andrew Savinykh,
      this is a very "interesting" behaviour. The PS2EXE host stops on error with ErrorActionPreference set to "Stop" -which is fine, but the error handler is not called in this case!
      I did not find the reason for the error yet, but I'm searching further and hope to present a solution soon.
    • Hello Andrew Savinykh,
      I corrected this error in the new version of PS2EXE that is available now.
  • Powershell under Java
    2 Posts | Last post November 21, 2017
    • Hallo Markus, 
      Great tool. I was able to write a Sharepoint Upload and convert the upload2sharepoint.ps1 into an exe and worked well. However now I try to start the upload2sharepoint.exe with p = Runtime.getRuntime().exec(command);	
      I see it starts it because it shows up in the TaskList. But it does not finish. I'm also writing a Textline in the beginning of the script to see if it hangs halfway, but it does not write to the file. So my feeling is that it responds with a message that you have to confirm/click. Do you know why this does not work and if the .exe might respond with a question/message if something is missing ?
      Best regards, 
    • Hello bjonms,
      I'm sorry I'm not familiar with SharePoint or Java, so I have no idea what's going wrong.
      For debugging purpose I would try to start the tool in a shell environment and redirect output, maybe you see hints in a log:
      cmd.exe /c upload2sharepoint.exe > C:\Output.log 2>&1
      I do not know if that works in Java. Makes only sense when compiled with PS2EXE in console mode (no parameter -noConsole).
  • Pop up boxes for every command run??
    5 Posts | Last post November 21, 2017
    • Converted my script using your tool to an exe.  But when I execute the exe a pop up box pops up for every line of command that runs.  I have to click ok on these boxes like 20 times till the script completes.  But when I run it from power shell normally it runs just fine.
      Any ideas why this will do that?
    • Hello BFrisan,
      I explained this behaviour for GUI programs (Parameter -noConsole) in the "Remarks" section of this web page:
      GUI mode output formatting:
      Per default in powershell outputs of commandlets are formatted line per line (as an array of strings). When your command generates 10 lines of output and you use GUI output, 10 message boxes will appear each awaiting for an OK. To prevent this pipe your command to the comandlet Out-String. This will convert the output to one string array with 10 lines, all output will be shown in one message box (for example: dir C:\ | Out-String).
      Hope this might help you.
    • Markus Scholtes...Thanks for your nice tool.
      How can avoid pop-ups with -1 and other output like disk size when mounting VHD etc., When I try with PS2EXE without GUI its not working with No console option. Thanks in advance.
    • Thanks Markus for your response.  Unfortunately that means nothing to me.  "new to scripting"  What a  co-worker did for me was put $temp = in front of the command and it stopped all the prompts.  
      Tool works great!
    • Hello BFrisan,
      what your co-worker adviced you is just fine, it supresses all the output.
      If the output of a single command produces several message boxes and you want to collect the output in one message box, you can pipe the output to Out-String.
      If for example the command 
      produces several messageboxes, then
      Start-Something | Out-String
      puts all text in one message box.
  • Need to avoid all -1 pop-ups in noConsole mode.
    2 Posts | Last post November 21, 2017
    • Markus Scholtes...Thanks for your nice tool.
      How can I avoid all kinds of pop-ups in noconsole mode. I don't want pop-ups with -1 and other output like disk size when mounting VHD etc., When I try with PS2EXE without GUI its not working with No console option. Thanks in advance.
    • Hello vvkprasad,
      since PS2EXE presents a message box for every output when used with the parameter -noConsole, this can be very annoying.
      To get rid of this you have to suppress the output of the commands you don't need. To do this, you might redirect the output, for example change a command
      cmdlet-withoutput | Out-Null
      But you have to identify the commands with unneeded output by yourself.
  • Changing Software Version
    2 Posts | Last post October 25, 2017
    • Is it may be  possibe to set a software Version oder Descripion in the Exe Details Properties?
    • Hello Mike-zdf,
      yes, you can the Version with the -Version Parameter and the description with the -title parameter, e.g.:
      .\ps2exe.ps1 test.ps1 test.exe -version -title "This is the description"
  • Problems with Running a simple script with a Form on Windows 7 and Windows 8+
    2 Posts | Last post October 14, 2017
    • Hi,
      I try to create some sort of settings executable, that should be run in our network. We have Windows 7 and newer computers. And here the problems start:
      If I compile it without any changes, the result runs on every computer, but not on Windows 7, because (after testing) it needs powershell 3 (at least). So I compliled it with the 2.0 option. Then it works great on Windows 7, BUT it needs .NET 3.5, which is not available on newer computers.
      So is there a way to create ONE exe, that runs on Windows 7 up to current systems? All our Windows 7 run .NET 4+, but nobody upgraded the powershell to 3.0...
      Best regards and thanx for the tool
    • Hello Martin,
      I'm sorry to say that I found no solution for your problem.
      There is no way for a .Net program that starts a powershell runspace (as PS2EXE does) to run unmodified on Windows 7 without Powershell V3 (or up) and on newer Systems with Powershell V3 without .Net 3.5!
      I tried to tweak PS2EXE.ps1, but there are always some DLLs missing in the generated executable.
      I guess you have to use a starter script that checks the Windows version and then starts the correct executable.
  • Arguments beginning with a slash are replaced with true
    3 Posts | Last post October 10, 2017
    • For a script
      param (
          [string]$wd = ""
      echo $wd
      And run with .\script.ps1 -wd "/etc/xyz", the output is True instead of the expected /etc/xyz
    • Hello shravan2x,
      this bug was intended to be a feature! I thought it would be fine that PS2EXE accepts a slash as an introducing character for named parameters too like cmd.exe does.
      Now it seems to be a bad idea as this leads to the error you mention.
      I will release a new version of PS2EXE in a few days that has this error fixed.
      Greetings and thanks
    • Hello shravan2x,
      I have released a new version of PS2EXE. Please check if the error is fixed.
141 - 150 of 184 Items