Skip to content

How to change Bat code to pure PowerShell code? #8

Description

@Davider-code

Thank you very much for the hard work of the developers of this project

I want to change the bat code into PowerShell code

My programming level is not good. I tried several times without success, so I want to ask the developer for help. Thank you in advance

In addition, I want to know how to customize the output path, for example: $path ='c:\ABC '

code1---bat

@echo off & color 07 & chcp 65001 >nul
set "0=%~f0" & powershell -nop -c $f=[IO.File]::ReadAllText($env:0)-split':bat2file\:.*';iex($f[1]); X 1
@pause & exit/b

:bat2file: Compressed2TXT v6.1
$k='$&Y5OqzhK#sx]F+~,);@m3CaWT0_/Hb(2ekj8N-pr^6ltQ{VndBGJ|SMEo[cvA?9yZ=f!}.i4XwgRDPuUI1L7'; Add-Type -Ty @'
using System.IO; public class BAT85 {public static void Dec (ref string[] f, int x, string fo, string key) { unchecked {
byte[] b85=new byte[256];long n=0;int p=0,q=0,c=255,z=f[x].Length; while (c>0) b85[c--]=85; while (c<85) b85[key[c]]=(byte)c++;
int[] p85={52200625,614125,7225,85,1}; using (FileStream o=new FileStream(fo,FileMode.Create)) { for (int i=0;i != z;i++) {
c=b85[f[x][i]]; if (c==85) continue; n += c * p85[p++]; if (p==5) {p=0; q=4; while (q > 0) {q--; o.WriteByte((byte)(n>>8*q));}
n=0;}} if (p>0) {for (int i=0;i<5-p;i++) {n += 84 * p85[p+i];} q=4; while (q > p-1) {q--;o.WriteByte((byte)(n>>8*q));} } } }}}
'@; cd -lit (Split-Path $env:0); function X([int]$x=1) {[BAT85]::Dec([ref]$f,$x+1,$x,$k); expand -R $x -F:* .; del $x -force}

:bat2file:[ test_txt
::W4Nj6$$$$$(+uW]$$$$$+]YEt$$$$$$1q8q$__#&Tz,rIC~$0}$__;T$II_5$$$$$$$5DaP6yG&Nk}Qa+uKH[$5iJ-$Yxja$$&vx$$#z&$$#z&$$#z&$q3mZ$$
:bat2file:]

code2---powershell--no't succeed

$_b = @'
::W4Nj6$$$$$(+uW]$$$$$+]YEt$$$$$$1q8q$__#&Tz,rIC~$0}$__;T$II_5$$$$$$$5DaP6yG&Nk}Qa+uKH[$5iJ-$Yxja$$&vx$$#z&$$#z&$$#z&$q3mZ$$
'@

$k='$&Y5OqzhK#sx]F+~,);@m3CaWT0_/Hb(2ekj8N-pr^6ltQ{VndBGJ|SMEo[cvA?9yZ=f!}.i4XwgRDPuUI1L7'; Add-Type -Ty @'
using System.IO; public class BAT85 {public static void Dec (ref string[] f, int x, string fo, string key) { unchecked {
byte[] b85=new byte[256];long n=0;int p=0,q=0,c=255,z=f[x].Length; while (c>0) b85[c--]=85; while (c<85) b85[key[c]]=(byte)c++;
int[] p85={52200625,614125,7225,85,1}; using (FileStream o=new FileStream(fo,FileMode.Create)) { for (int i=0;i != z;i++) {
c=b85[f[x][i]]; if (c==85) continue; n += c * p85[p++]; if (p==5) {p=0; q=4; while (q > 0) {q--; o.WriteByte((byte)(n>>8*q));}
n=0;}} if (p>0) {for (int i=0;i<5-p;i++) {n += 84 * p85[p+i];} q=4; while (q > p-1) {q--;o.WriteByte((byte)(n>>8*q));} } } }}}
'@

function X([int]$x = 1) { [BAT85]::Dec([ref]$_b, $x + 1, $x, $k); expand -R $x -F:* .; del $x -force }

X 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions