Last active
August 29, 2015 14:19
-
-
Save hallvors/eb4a622686bf87cbb4bb to your computer and use it in GitHub Desktop.
Testing how Windows handles quoted paths in a batch file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
set SLJS_TEST=%SLJS_TEST% | |
echo. | |
echo No quotes added. Path is %SLJS_TEST% | |
echo. | |
if exist %SLJS_TEST% ( | |
echo "UNQUOTED: This path DOES exist: %SLJS_TEST%" | |
) | |
if not exist %SLJS_TEST% ( | |
echo "UNQUOTED: This path does NOT exist: %SLJS_TEST%" | |
) | |
echo. | |
if exist "%SLJS_TEST%" ( | |
echo "QUOTED IN EXISTS STATEMENT: This path DOES exist: %SLJS_TEST%" | |
) | |
if not exist "%SLJS_TEST%" ( | |
echo "QUOTED IN EXISTS STATEMENT: This path does NOT exist: %SLJS_TEST%" | |
) | |
echo. | |
echo. | |
set SLJS_TEST="%SLJS_TEST%" | |
rem set SLJS_TEST="c:\Program Files (x86)\Mozilla Firefox\firefox.exe" | |
echo. | |
if exist %SLJS_TEST% ( | |
echo QUOTE PART OF VALUE, UNQUOTED STATEMENT: This path DOES exist: %SLJS_TEST% | |
) | |
if not exist %SLJS_TEST% ( | |
echo QUOTE PART OF VALUE, UNQUOTED STATEMENT: This path does NOT exist: %SLJS_TEST% | |
) | |
echo. | |
echo. | |
if exist "%SLJS_TEST%" ( | |
echo QUOTE PART OF VALUE, QUOTED STATEMENT: This path DOES exist: %SLJS_TEST% | |
) | |
if not exist "%SLJS_TEST%" ( | |
echo QUOTE PART OF VALUE, QUOTED STATEMENT: This path does NOT exist: %SLJS_TEST% | |
) | |
echo. | |
echo. | |
rem if exist "%programfiles%\Mozilla Firefox\firefox.exe" ( | |
rem SET "SLIMERJSLAUNCHER=%programfiles%\Mozilla Firefox\firefox.exe" | |
rem ) | |
rem if exist "%programfiles(x86)%\Mozilla Firefox\firefox.exe" ( | |
rem SET "SLIMERJSLAUNCHER=%programfiles(x86)%\Mozilla Firefox\firefox.exe" | |
rem ) | |
rem echo "Found Firefox here: %SLIMERJSLAUNCHER%" |
Win 8.1:
No quotes added. Path is C:\Program Files (x86)\Nightly
"UNQUOTED: This path DOES exist: C:\Program Files (x86)\Nightly"
'Files' is not recognized as an internal or external command,
operable program or batch file.
"UNQUOTED: This path does NOT exist: C:\Program Files (x86)\Nightly"
"QUOTED IN EXISTS STATEMENT: This path DOES exist: C:\Program Files (x86)\Night
y"
QUOTE PART OF VALUE, UNQUOTED STATEMENT: This path DOES exist: "C:\Program File
(x86)\Nightly"
QUOTE PART OF VALUE, QUOTED STATEMENT: This path DOES exist: "C:\Program Files
x86)\Nightly"
'Files' is not recognized as an internal or external command,
operable program or batch file.
QUOTE PART OF VALUE, QUOTED STATEMENT: This path does NOT exist: "C:\Program Files (x86)\Nightly"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Same on Win8 64bit)