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

  • Passing arguement
    5 Posts | Last post August 09, 2019
    • Hi Markus, I used PS2exe for converting .ps1 file. My ps1 file takes 2 arguments during installation. ie, .\my.ps1 "arg1","arg2". arg1 is used by an exe for installation. When I run from ps1, the exe takes arg1 as per the required logic but when I run ps2exe converted exe it takes both the arguments(arg1 and arg2)as input parameter which is causing issue. I verified the same by running process explorer. It would be very kind of you if you could help me.
    • Hello Abby Potter,
      I can explain this behaviour, but can not do anything about it because it's not under PS2EXE's control. When you pass "arg1","arg2" to a PowerShell script, an Array is passed to the script. If you pass "arg1","arg2" to an executable, the shell passes a string to the executable. So the string with the value "arg1","arg2" is the first parameter.
      Is it possible for you to set a blank after the comma? Could you omit the comma? This might work.
    • Hi Marcus, I believe I found the issue. When I was compiling to EXE I was using an older PS2EXE.ps1 powershell and not the one that was in your folder. When I tried your PS2EXE.ps1 the parameters now work.
      The path of my environment variable was kicking off another version of PS2EXE. 
      Thank you for all your help :)
    • Hello Alice Martini,
      are you sure you're answering to the correct question?
    • Oops, sorry for the wrong post. 
  • Include multiple files.
    2 Posts | Last post August 07, 2019
    • How can i modify this script so that i can include multiple files in the exe?
    • Hello Jerald4lyfe,
      I think I cannot fulfill the wish you have. There are to many things PS2EXE would have to determine or could not predict: the path to a sub script might have to be evaluated at runtime, variables might have a (sub) script scope, parameters to sub scripts have to be handled, script variables might have different values in sub scripts...
      Maybe a tool that generates self extracting archives would be better for you.
  • Thank you, Markus!
    2 Posts | Last post August 07, 2019
    • I compiled the script on a Win7 PC and the EXE is working perfectly. It's no problem for us to have a separate EXE for Win10 and one for Win7. I appreciate your advice, thanks again!
    • You're welcome.
  • Adding to my question
    2 Posts | Last post August 04, 2019
    • Sorry, I don't see an edit button for my previous post. I do have .Net Framework 4.7.2 on the Windows 7 PCs. The PowerShell version on the PC in question is 2.0.
    • Hallo Carl,
      PowerShell 2.0 always runs with .Net 2 up to .Net 3.51 and cannot use .Net 4.xx. You have two options:
      1. Compile your script with PowerShell 2.0 on your Windows 7 PC (this executable will fail on your Windows 10 PC if there is no PowerShell 2.0 present)
      2. Install WMF 3 or up on your Windows 7 PC, so PowerShell 3 or up are present
  • EXE crashing only on Windows 7
    2 Posts | Last post August 04, 2019
    • Hi Markus!
      I'm guessing that my Windows 7 PCs are missing a prerequisite but I'd like to run this by you just in-case.
      The Posh script that I converted to EXE is
      Copy-Item "C:\Users\$env:UserName\Appdata\Roaming\Microsoft\Sticky Notes\StickyNotes.snt" -Destination "Z:\Userdata\StickyNotes\StickyNotes.snt"
      The EXE runs and copies the data on Windows 10, but it fails on Windows 7. The error message that I get is
      Faulting module name: KERNELBASE.dll, version: 6.1.7601.24499, time stamp: 0x5d0115f1
      Exception code: 0xe0434352
      Fault offset: 0x000000000000b87d
      Please advise if you can, thank you!
    • Answer above...
  • Providing parameters to the EXE
    4 Posts | Last post August 02, 2019
    • After 'compiling' the PS to EXE I can't find a way to pass specific parameters as I could when it was a PowerShell script. Normally I could do: 
      SQL.ps1 -Tablename Employee -ACCNO 43214...
      Now that it's an exe it doesn't accept the paramter name. 
      Is there a way to pass specific named parameters to the executable? 
    • Hello Alice Martini,
      parameters are passed to the executable the same way as you pass it to a powerShell script, for your example:
      SQL.exe -Tablename Employee -ACCNO 43214...
      But there is a - for same cases big - restriction since it is an executable: all parameters are interpreted as of type [STRING]. There is nothing I can do about this, it is a restriction of way executables are called.
    • Thank you so much Markus for the quick response :)
      Unfortunately when the exe is compiled, the exe treats the paramter name as the actual value: 
      Here's my Powershell (x.ps1) that I convert to an EXE:
      write-host $name
      write-host $sex
      After compilation when I try to put in parameters x.exe -name Marcus -Sex male but i get the following
      the value of $name = "-Name" 
      the value of $sex = "Marcus"
      I've tried everyithing I could. the only thing that works is: x.exe Marcus Male
      (without any paramter names).
    • Hello Alice Martini,
      I'm sorry I to have to say I can't recreate your problem. In my environment everything's working fine.
      How do you call the executable x.exe? What PowerShell and what Windows version you are using? Are you sure you did not copy the code out of Word or another application and are unintentionally using "EN DASH" characters (ASCII code 0x96) instead of the regular "hyphen minus" (ASCII code 0x2d)?
  • How to suppress display of parameter and minimize the console
    2 Posts | Last post July 26, 2019
    • Hi Markus, I used PS2EXE.ps1 for converting my ps1 file to exe. My ps1 takes arguments, and when I pass the arguments to exe file it displays argument value in the console which I don't want. Also I want to minimize this console during installation. I can minimize the windows using "-WindowStyle Minimized" in PS1 file. 
      Could you help me.
    • Hello Abby Potter,
      are you sure you want a console program? Maybe you compile your script with the Parameter -NoConsole?
      But remember, every output will generate a message box then.
  • Flagged by Anti Virus
    2 Posts | Last post July 24, 2019
    • After compiling using the tool using the GUI version my EXE's are being flagged by ESET Antivirus as a trojan. Compiling through the command line does not cause this.
    • Hello Cole,
      I uploaded a file compiled directly with the script PS2EXE.ps1 and a script compiled using WinPS2EXE to VirusTotal. The ESET antivirus rated both executables "unsuspicious".
  • How do you detect the run path automatically?
    2 Posts | Last post July 10, 2019
    • When the powershell script is compiled the normal principles for automatically determining the run directory no longer seem to working. For example if a mypowershellscript.exe is in c:\temp\mypowershellscript.exe how would I get the parent directory of the exe? As the $MyInvocation don't seem to be populated.
    • Hello CASWEBSI,
      please see the description in the Remarks section of this web page ("Script variables:").
  • Suggestion
    6 Posts | Last post July 01, 2019
    • Hello,
      I have a suggestion:
      Add this to the manifest xml
      <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
          <!--The ID below indicates application support for Windows Vista -->
            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
          <!--The ID below indicates application support for Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
          <!--The ID below indicates application support for Windows 8 -->
            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
          <!--The ID below indicates application support for Windows 8.1 -->
            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
          <!--The ID below indicates application support for Windows 10 -->
            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
      This will avoid "Program Compatibility Assistant" Message (This program might not have installed correctly) popping up after exiting the executable, if its file/product name contain any of these words:
      Setup, Install, Installer, Installation, Uninstall
    • Hello Romeo Montague,
      I will do some Research About this Topic.
    • Hello Romeo,
      seems to be useful to make a parameter for this. I will implement it in the next version.
      Maybe you can work around until then with the option -x64 if 64 bit is applicable for you.
    • Hello Markus,
      thank you, but I had already modified a previous version, should have posted it right away. There is a manifest xml included by default which isn't in the ps2exe.ps1, so I took it and added the above snippet.
      $reqAdmParam = ""
      if ($requireAdmin)
      	$execLvl = "requireAdministrator"
      	$execLvl = "asInvoker"
      $win32manifest = "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>`r`n<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0"">`r`n  <!--<assemblyIdentity version="""" name=""""/> -->`r`n  <trustInfo xmlns=""urn:schemas-microsoft-com:asm.v2"">`r`n    <security>`r`n      <requestedPrivileges xmlns=""urn:schemas-microsoft-com:asm.v3"">`r`n        <requestedExecutionLevel level=""$execLvl"" uiAccess=""false""/>`r`n      </requestedPrivileges>`r`n    </security>`r`n  </trustInfo>`r`n  <compatibility xmlns=""urn:schemas-microsoft-com:compatibility.v1"">`r`n    <application>`r`n      <!--The ID below indicates application support for Windows Vista -->`r`n        <supportedOS Id=""{e2011457-1546-43c5-a5fe-008deee3d3f0}""/>`r`n      <!--The ID below indicates application support for Windows 7 -->`r`n        <supportedOS Id=""{35138b9a-5d96-4fbd-8e2d-a2440225f93a}""/>`r`n      <!--The ID below indicates application support for Windows 8 -->`r`n        <supportedOS Id=""{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}""/>`r`n      <!--The ID below indicates application support for Windows 8.1 -->`r`n        <supportedOS Id=""{1f676c76-80e1-4239-95bb-83d0f6d0da78}""/>`r`n      <!--The ID below indicates application support for Windows 10 -->`r`n        <supportedOS Id=""{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}""/>`r`n`r`n    </application>`r`n  </compatibility>`r`n</assembly>"
      $win32manifest | Set-Content ($outputFile+".win32manifest") -Encoding UTF8
      $reqAdmParam = "`"/win32manifest:$($outputFile+".win32manifest")`""
    • Hello Romeo,
      you are too late with this comment. The new version of PS2EXE with the parameter -supportOS is ready and will be published on Monday.
    • Hello Romeo,
      I released the new version V0.5.0.16 today that addressing your issue with the new parameter -supportOS.
41 - 50 of 171 Items