How do you generate a batch file for windows .bat using msfvenom, msfvenom does not seem to have a batch file like format and is it possible to convert a .ps1 to .bat file

1 Answer 1


A .ps1 file is a PowerShell script: unlike .bat and .cmd it's executed in Windows PowerShell instead of the Windows cmd.exe. While it's possible to "convert" a PowerShell script into a batch script that calls PowerShell, the requirement for the PowerShell framework remains.

If that's what you are looking for, for a longer script like the one produced by msfvenom, I'd suggest the method explained in Dmitry Sotnikov's PowerShell script in a .bat file:

  1. Put the code inside curly brackets and assign it to a variable.

    $code = {
        # code here
  2. Base64 encode it with PowerShell:

  3. Use it in your batch script with powershell.exe -EncodedCommand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.