how to embed shell script within a .BAT file

Jeremy Bopp
Fri Nov 7 21:48:00 GMT 2014

On 11/07/2014 03:26 PM, Nellis, Kenneth wrote:
> I'm tired of creating pairs of script files:  a clickable .BAT file 
> to invoke my shell script and then my shell script to do the actual
> work. I was wondering if any of the geniuses on this list have come 
> up with a way to embed a shell script inside a clickable .BAT file.
Something like this might do.  It assumes you know the path to the
Cygwin bin directory.  Passing in arguments would be a bit more work and
would probably be somewhat limited unless you have a small number of
possible arguments.

FYI, I don't have a Windows system readily available anymore, so this is


@echo off

rem Put Cygwin bin directory into PATH
set PATH=C:\cygwin\bin;%PATH%

type %0 | sed "0,/^---BASH SCRIPT FOLLOWS---/ d; s/\r*$//" | bash
goto :eof

echo $SHELL is alive


Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list