How to convert a custom file type from.ps1 to.exe?

tj_zero 65 Reputation points
2023-09-12T05:56:02.7533333+00:00

I want to convert my own powershell script to an .exe executable so that it can be run directly;

Hope the engineer can provide any of the following help:

  1. ps1 conversion exe free open source tool software download connection; (Recommended)
  2. Use the existing system environment of Windows11 to execute the corresponding command conversion; (If the system does not need to rely on third-party open source tools can also be implemented)

Above, hope to get your help, thank you;

Windows for business Windows Server User experience PowerShell
{count} vote

3 answers

Sort by: Most helpful
  1. Konstantinos Passadis 19,586 Reputation points MVP
    2023-09-16T22:06:18.95+00:00

    Hello @tj_zero !

    You can achieve this with the use of PS2EXE

    https://github.com/MScholtes/PS2EXE

    I think it really has some nice features that can help you a lot !


    I hope this helps!

    Kindly mark the Answer as Accepted and upvote or post your feedback to provide additional help!

    Regards!

    0 comments No comments

  2. MotoX80 36,291 Reputation points
    2023-09-22T17:52:22.8033333+00:00

    It looks like you have 2 problems. The first is some issue with Invoke-ps2exe. For that one, I would think that you need to provide the .exe file name and not just the folder name in the Target file field.

    User's image

    If Powershell is not able to successfully execute your .ps1 script, then it may be that the encoding of the .ps1 file is not able to store whatever that last character in the password is. When using notepad, do a SaveAs and make sure that the encoding is set to either UTF-8 or "UTF-8 with BOM".

    When testing, modify "bl.bat" to just do something simple like "timeout.exe /t 10" instead of any Bitlocker process.

    If Powershell is able to execute the .ps1 file, then the most obvious conclusion would be that PS2EXE is unable to handle that last character.

    In that case, try changing the password.

    User's image

    0 comments No comments

  3. tj_zero 65 Reputation points
    2023-10-09T04:06:48.3933333+00:00

    Sorry for the late reply;

    Have tried many times but have not succeeded;

    I guess I'm not very proficient in using the software;

    I wonder if I can get your help again.

    Look forward to your news, thank you;


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.