Skip to content

Instantly share code, notes, and snippets.

@phizaz
Created February 9, 2017 16:53
Show Gist options
  • Save phizaz/959cf9562f8c003de2490490c9e92db8 to your computer and use it in GitHub Desktop.
Save phizaz/959cf9562f8c003de2490490c9e92db8 to your computer and use it in GitHub Desktop.
Batch script that escapes %cd% and %home% by using ${cd} and ${home} instead
@echo off
REM run command by parsing ${cd} to %cd% and ${home} to %home%
setlocal ENABLEDELAYEDEXPANSION
set str=%*
set str=!str:${cd}=%CD%!
set str=!str:${home}=%HOME%!
REM run the parsed command
%str%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment