BAT to EXE

There are many bat2exe tools out there, or more appropriately a wrapper (not a compiler anyhow). But I think mine is the one that its resulting exe behave like a proper cmd apps. It's based on modified 7zip SFX module. It's called portabat

Features

  • Simple editing, just open it with 7zip and put your batch files there.
  • Your batch files always executed regardless Windows policy to disable command prompt
  • Can be passed command arguments 
  • Behave as multi-call batch launcher based on its SFX name (matched to .bat/.cmd name inside)
  • Your batch files always executed regardless Windows policy "disable command prompt"
  • Have standalone reg which bypass Windows policy "disable registry tools"
  • Your other executables / batch files in the \bin sub-directory will available in PATH lookup 
  • Executed at the "correct" working directory
  • Do not spawn new cmd box if called from existing cmd box (always reuse existing console)
  • Can be called (and have the correct working directory) from anywhere inside PATH environment
  • Your echo %%~nx0 is echo %SFX%
  • Your SFX path is %SFXPATH%
  • Your extraction path is %~dp0
  • Largely compatible cmd.exe from ReactOS
  • Can handle inf files as well (DefaultInstall entry)
  • If cwd file exist in the archive, current directory will be temp. extraction path
  • Be sure to always reference other files/folder in archive with %~dp0 prefix
  • Batch filename execution order (prefer .bat over .cmd)
  • Compatible with XP or later

 

Download 

version 0.2:
github.com/tumagonx/portabat

What's Bundled?

Inside the tiny 350KB executable there is more than 70 tools (curated from the internet) for different area of interest. Sources are available with exception for MS forfiles, rvkroots and updroots). All tools are LFS aware and with exception for gsar and busybox are Unicode filename aware.

Programming

cmd.exe : Batch processor from ReactOS which at runtime automatically override Windows CMD. Batch while considered lacking as a language is still good for file processing. Recommended to call it as %COMSPEC%
https://ss64.com/nt/

busybox.exe awk : Posix awk from busybox for heavy-duty text processing that goes beyond sed and grep
http://www.grymoire.com/Unix/Awk.html
https://www.gnu.org/s/gawk/manual/gawk.html

autoit3.exe : Old GPL version of AutoIt 3.0.102 is one of most popular UI automation language, while its role in assisting batch task may minimal, it's still important addition in the Windows environment.
https://www.autoitscript.com/wiki/Tutorials

All those three intended to run script file .bat/.cmd, .awk and .au3 respectively

File Management

rawcopy.exe : Low-level copy/imaging from/to device/pipe by Olof Lagerkvist
type rawcopy -h to see help
example:
rawcopy -m diskimage.img \\.\A:
Writes a diskette image file called "diskimage.img" to a physical diskette in drive A:.
rawcopy \\.\PIPE\MYPIPE ""
Reads data from named pipe "MYPIPE" on the local machine and write on standard output.
rawcopy 1 \\.\PhysicalDrive0 parttable
Copies sector 1 (partition table) from first physical harddrive to file called "parttable".

partfile.exe : File partial copy/peek and split
example:
partfile foo.iso bar.part 20000 64000
copy 64000 bytes of foo.iso starting from offset:20000 into bar.part
partfile foo.iso bar.part - 64
split foo.iso into 64 pieces of bar[n].part
partfile foo.iso bar.part - 1000000
split foo.iso into pieces of 1000000 bytes bar[n].part

junc.exe and hardlink.exe : Pair of fallback replacement for mklink for example to support Windows XP NTFS. This create symlink for directory (junc) or file (hardlink). From Olof Lagerkvist with minor modification on junc

chsize.exe : Create new file (or NTFS sparse) at arbitrary size. From Olof Lagerkvist

makelnk.exe : Shortcut .lnk file creation from ReactOS

lzma.exe : Raw data (de)compressor (not to be confused with 7za), for flat file such disk image or pipe stream.
example:
dir /s c:\windows\*.* | lzma e c_snapshot.lzma -si
take file structure snapshot of windir in compressed form

cabit.bat : Cabinet archiver front-end for makecab

un7z.exe : 7zip 17.x compatible extractor

dezip.exe : unzip file using windows built-in feature

touch.exe : File timestamp

busybox.exe hd/hexdump/xxd : View/peek binary files

busybox.exe diff and patch : compare two text, no better than FC IMO but it has defacto formatting used by patch

busybox.exe psort (renamed sort) : Posix sort filter based various criteria

busybox.exe du : Show directory size in various way

gsar.exe : Search and replace file content, support binary

isoimage.exe : Create ISO image of CD (iso9660+joliet+udf) or DVD (udf only) from directoy recursively, optionally with boot file. On XP this need imapi2 update which NOT part of SP3.

isohybrid.exe : Turn iso image into flexible boot disc
type isohybrid -? for help

eltorito.exe  : Retrieve boot image from iso/disc

wincrypt.exe : Encrypt file using Windows AES feature

winhash.exe : Return hash of file in MD, SHA, or CRC

genuuid.exe : Generate UUID, useful for naming temporary file.

isdrive.exe : Return type of current/specified drive

Process Management

ppx2.exe : Parallel processing similar to xargs, works via piping. Note that it doesn't work (in parallel) if piping feed and done inside for loop.
example:
dir /S /B /Ahs-d /Od *.png | ppx2 -P 8 -L 1 gdipconv "{}" "{}.jpg"
dir /S /B /Ahs-d /Od *.png | ppx2 -P 8 -L 1 %COMSPEC% /c gdipconv "{}" "{}.jpg" ^&^& del "{}"
Convert all png to jpg image at 8 parallel task, notice the result will have .png.jpg suffix
second example use batch command del which require passing cmd and escaping ampersand.

busybox.exe tee : Stdin/stdout redirector

timer.exe and timeout.exe : Measure process time or give a delay

fwpipes.exe : Named pipes data transfer of two program by Olof Lagerkvist

setprio.exe : Control process affinity

getppid.exe : Get parent pid

System Query

reg.exe : Registry query/editor from ReactOS that works independently regardless of Windows' registry policy

getwu .exe : Query windows updates and get download links

showwin and enumwim  : window handle control and query

Internet

rvkroots.exe and updroots.exe : Two Microsoft retired (but usable) helpers that manage certificate in Windows keystore. These are for old XP only and not needed on new Windows

dwnl.exe : Native ftp/http/https downloader from ReactOS
example:
dwnl http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/authroots.sst
dwnl http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/delroots.sst
dwnl http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/roots.sst
dwnl http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/updroots.sst
dwnl http://www.download.windowsupdate.com/msdownload/update/v3/static/trustedr/en/disallowedcert.sst
updroots.exe authroots.sst
updroots.exe updroots.sst
updroots.exe -l roots.sst
updroots.exe -d delroots.sst
rvkroots.exe -l -u disallowedcert.sst

Perform certificates update on OS with expired support such XP

busybox.exe uuencode and uudecode

busybox.exe ipcalc

busybox.exe base64

Text Processing

iconv.exe : Text file codepage conversion

msxsl.exe : Microsoft xslt processor using msxml4

busybox.exe grep/egrep/fgrep : Perform posix regular expression search

busybox.exe sed : Stream text editor with regex

busybox.exe shuf : shuffle lines of text

busybox.exe cut and paste

busybox.exe rev : Reverse a text file 


Misc

busybox.exe pdate (renamed date) : represent date in various ways


busybox.exe seq : Number sequencer to complement FOR /L with padding option

busybox.exe dc : Reverse polish (RPN) calculator

busybox.exe factor : Calculate prime factor

msgbox.exe : Create message dialog for notification

pclip.exe : paste/copy clipboard content, used with windows clip command


See old original post for comment:
http://opensourcepack.blogspot.com/2013/04/a-simple-bat-to-exe-wrapper.html

1 comment: