Skip to content

Instantly share code, notes, and snippets.

@jessenic
Forked from timheuer/foo.bat
Created November 30, 2012 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessenic/4177573 to your computer and use it in GitHub Desktop.
Save jessenic/4177573 to your computer and use it in GitHub Desktop.
batch with spaces
SET arch=%processor_architecture%
SET "pf=C:\Program Files"
if "%arch%" == "AMD64" (
SET "pf=C:\Program Files (x86)"
)
REM below does not fail even though "pf" has spaces in it
copy "\\some\path\file.foo" "%pf%\bar\baz\file.foo"
REM I would do it like this:
IF DEFINED PROGRAMFILES(X86) (SET "pf=%PROGRAMFILES(X86)%") ELSE (SET "pf=%PROGRAMFILES%")
ECHO %pf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment