windows


Eval script containing PATH in Windows CMD


I need to eval the commands thrown by some command 'minishift oc-env' which has PATH in it.
However, it seems that it is overwriting the whole PATH variable.
C:\Users\budhram>echo %PATH%
C:\Program Files\Docker\Docker\Resources\bin;C:\Users\budhram\AppData\Local\Temp;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;.....
C:\Users\budhram>minishift oc-env
SET PATH=C:\Users\budhram\.minishift\cache\oc\v1.5.0;%PATH%;
REM Run this command to configure your shell:
REM #FOR /f "tokens=*" %i IN ('minishift oc-env') DO #%i
C:\Users\budhram>SET PATH=C:\Users\budhram\.minishift\cache\oc\v1.5.0;%PATH%;
C:\Users\budhram>echo %PATH%
C:\Users\budhram\.minishift\cache\oc\v1.5.0;C:\Program Files\Docker\Docker\Resources\bin;C:\Users\budhram\AppData\Local\Temp;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;....
C:\Users\budhram>#FOR /f "tokens=*" %i IN ('minishift oc-env') DO #%i
C:\Users\budhram>echo %PATH%
C:\Users\budhram\.minishift\cache\oc\v1.5.0;%PATH%;
Any idea how we can do that?
This answer http://stackoverflow.com/a/9370376/1120530 also suggest about using setlocal enableDelayedExpansion which seems to be not working in my case.
When you run
#FOR /f "tokens=*" %i IN ('minishift oc-env') DO #%i
the do clause will execute
SET PATH=C:\Users\budhram\.minishift\cache\oc\v1.5.0;%PATH%;
which seems correct, BUT the problem is that after %i has been expanded to the indicated command, there is not a second expansion to convert %PATH% to the value in the variable.
You can try with
#FOR /f "tokens=*" %i IN ('minishift oc-env') DO #call %i
where the call command will force a second parse phase that will expand the %PATH% reference.

Related Links

Batch: use multiple files with same extension as a single argument?
Bower request error, status code: 400, ECONNRESET, when install packages on windows
SignTool Certificate Location for non-Admin user
How to create a exe file from an elixir project
How to run batch file for PostgreSQL from any place?
How to add user to a specific domain in Active Directory
Resolving long path (>260 char) limitation for accessing files/folders in latest Windows 10 build using Javascript
Run multiple instances of same executable from powershell
Application error. The application was unable to start correctly (0x000007b).Click Ok to close the application
Limit Access to WinRM services via IP
How do I determine if an EXE (or DLL) participate in ASLR, i.e. is relocatable?
How can i send gulp's sitespeedio results to Graphite (windows)
How to write the Path of a file to window upload file and press enter to upload with command line or autoit
Different 'Run As Admin' behavior in Win 8.1 / Win 10?
Error: Cannot find module '../lib/npm.js'
BATCH Preventing users from opening file from outside the program?

Categories

HOME
fabricjs
assembly
cobalt
time-complexity
android-studio-2.2
zend-framework
apiblueprint
shiro
entity-framework-core
echo
missing-data
augeas
distribution
mautic
google-picker
google-maps-autocomplete
ag
user-experience
inno-download-plugin
zxing
flooding
datastax-enterprise-graph
paperjs
magento-1.8
google-cast
mockjax
kodi
jbutton
spring-security4
instantiation
fossil
jwplayer6
slacktextviewcontroller
numpy-broadcasting
flatmap
nohup
c9.io
apache-stanbol
plaintext
linqpad
logback-groovy
memory-mapping
optimizely
plan-9
double-click
openresty
textsum
clarifai
static-cast
semantic-logging
context-sensitive-grammar
django-1.10
shinobi
materialized-path-pattern
simplepie
redistributable
windows-azure-queues
scaffolding
jclouds
omniauth-facebook
cda
boost-serialization
ikiwiki
crouton-os
grgit
haskell-warp
cwrsync
android-cookiemanager
sonarqube-5.0
genymotion-call
wcm
tweenlite
jama
ss7
gnumeric
renderer
ora-06550
light
cmmi
nebula
composite-component
virtual-pc
dopostback
listitem
usertype
urlrewriter
quotation-marks
ie-compatibility-mode
facebook-iframe
globals
strtod
visualj#
alsb
perl5.12
pbcopy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App