Making use of Environment Variable string
substitution syntax,
and the FOR %variable IN (set) DO command command, you can use the command-line, or a batch,
to display the folders in your %PATH%, one per line:
Command-line
for %f in ("%PATH:;=" "%") do @echo %fBatch
for %%f in ("%PATH:;=" "%") do @echo %%fIf you wish to also strip the encapsulating quote marks ("), you can add parameter parsing:
Command-line
for %f in ("%PATH:;=" "%") do @echo %~fBatch
for %%f in ("%PATH:;=" "%") do @echo %%~fExamples:
If your %PATH% contains:C:\Program Files\Windows Resource Kits\Tools\;C:\WIN_ONE;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\UTIL
Typing for %f in ("%PATH:;=" "%") do @echo %f would return:
"C:\Program Files\Windows Resource Kits\Tools\" "C:\WIN_ONE" "C:\WINDOWS\system32" "C:\WINDOWS" "C:\WINDOWS\System32\Wbem" "C:\UTIL"while typing for %f in ("%PATH:;=" "%") do @echo %~f would return:
C:\Program Files\Windows Resource Kits\ToolsC:\WIN_ONE C:\WINDOWS\system32 C:\WINDOWS C:\WINDOWS\System32\Wbem C:\UTIL
NOTE: What is happening with ("%PATH:;=" "%"):
1. The leading " inserts a quote mark at the beginning of the set.
2. The %PATH:;=" "% replaces all ;s with " ", defining the end of each folder path and the beginning of the next.
3. The trailing " inserts a quote mark at the end of the set.
0 comments
Hide comments