Using Cygwin on Windows, sometimes you need to run a bash command or script from the Windows command line (CMD, DOS, shell). This is particularly useful if you want to use the Task Scheduler instead of messing with cron on cygwin. If you’re going to schedule tasks on a Windows system, then the Windows Task Scheduler is probably the sane way to do it.

To run a bash script or command from outside of cygwin, you need to pass it to the bash executable with a little prep work. That “prep work” is contained in the following script (adapted from here), called cygrun.bat:

::Use this script to run bash commands 
::from the Windows CMD (DOS) prompt.
::Pass the bash script or commands as arguments to this .bat.
::If no arguments are passed, a bash interactive shell starts.

@echo off
    if "%DEF_PATH%"=="" set DEF_PATH=%PATH%
    ::Do _not_ surround path with quotes, even if paths have whitespace.
    set PATH=c:\cygwin\bin;%DEF_PATH%
    set args="%*"
    if "%args%"=="" goto noarg
    bash --rcfile %HOMEPATH%/.bashrc -i -c "%args%"
    sleep 1
    goto exit

    bash --login -i


Then call that script, passing the bash script (or commands) to it as arguments.

C:\path\to\cygrun.bat /cygdrive/c/path/to/


  • the argument(s) to cygrun.bat uses Cygwin bash (Unix) path syntax.
  • If you have msysgit cygwin (instead of ‘vanilla’ cygwin), its bin directory is located somewhere like c:\Program Files\Git\bin.