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.
4.7 Star
34,257 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • 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.
  • How to make the console output windows 132 characters wide
    3 Posts | Last post October 08, 2017
    • Hi Markus,
      first of all, my compliments for the wonderful job!
      I would like to know if there is a way to make the console output windows 132 characters wide. I need it to avoid the wrap-around of the output messages of my script....
    • Hello lastbutnotleast,
      I think I do not understand your question.
      The console output is not wrapped by PS2EXE and the size of the console window can be set by using $Host.UI.RawUI.WindowSize as in any powershell script.
      Can you explain your situation more detailed?
    • Markus,
      thank you very much for your support. Your answer has been enlightening :-)
      I usually run scripts from ISE, so I never had to worry about the console window size. Now I understand how to solve my simple problem ;-)
  • Can we increase the parameter prompt textbox to at least 100px by default
    2 Posts | Last post October 06, 2017
    • Thanks Markus
      This is working fine with parameters now. Is there a way that I can increase the prompt textbox width to at least 100px?
    • Hello xja888,
      hope I got your question right: you want the textfield in the inputbox to be always at least 100px wide?
      To accomplish this you have to do the following change to ps2exe.ps1:
      Open ps2exe.ps1 with your favourite text editor and change line 938 from
      textBox.SetBounds(12, label.Bottom, label.Right - 12, 20);
      textBox.SetBounds(12, label.Bottom, Math.Max(label.Right - 12, 100), 20);
      (you might search for the expression "textBox.SetBounds" to find the correct line)
  • NoConsole parameter and unwanted popup when closing the window
    3 Posts | Last post October 02, 2017
    • Hi Markus,
      First of all, thank you for all your job. I'm very happy to use it !
      However I have a little issue with the -NoConsole parameter :
      As soon as I add the -NoConsole parameter, there's a popup window which appears when I close the form (with "myFileName.exe" as window title and "Cancel" text as value).
      How can I rid off that unwanted last window please ?
      Thank you very much,
    • Hello Anthony 974,
      I have a guess what the reason for this behaviour is:
      You start the windows form window somewhere in your script with a command similiar to this (the name of the variable $Form may vary):
      You have to change it to
      as the command returns the text "Cancel" which is then displayed in a message box. [VOID] "eats" everything returned, so "Cancel" is not displayed anymore.
    • It works !
      Thank you very much for the tips and the explanation.
      I'd like to point your reactivity to answer questions which in my opinion is very fast.
      Best regards,
131 - 140 of 171 Items