#how to get back the """source code""" of a ps2exe exe ?

4 messages · Page 1 of 1 (latest)

drifting edge
#

.

bronze plume
#

Look at the dnspy application.

lone dock
#

If you want to restore the exe compiled by PS2EXE, you can use the -extract:./a.ps1 parameter directly on the command line to fish the code (if the target exe is compiled by ps12exe this method will not work, but if the exe file is not packed, you can try any .net decompiler, it generally works)
If you want to use the contents of the ps file inside the ps code, you can get the source code of the exe in the exe compiled by ps12exe using the $PSEXEscript variable
you can refer to this:

#_pragma Console 0
if(-Not (Get-Module -ListAvailable -Name ps12exe)) {
    Install-Module ps12exe -Force -Scope CurrentUser -ErrorAction Ignore
}
Import-Module ps12exe -ErrorAction Stop
$Number = [bigint]::Parse('0')
$NextNumber = $Number+1
$NextScript = $PSEXEscript.Replace("[bigint]::Parse('$Number')", "[bigint]::Parse('$NextNumber')")
$NextScript | ps12exe -outputFile $PSScriptRoot/$NextNumber.exe *> $null
$Number