I am verry new in batch command, here my problem
This is my script :
@echo off
title This is xx
echo welcome
set currentdir=bash -c 'wslpath -a "C:\Users\Administrator"'
set curdir=%currentdir%
echo %curdir%
echo test
pause
Output :
welcome
bash -c 'wslpath -a "C:\Users\Administrator"'
test
Press any key to continue . . .
Output for my command is :
C:\Users\Administrator>bash -c 'wslpath -a "C:\Users\Administrator"'
/mnt/c/Users/Administrator
So, i want execute the command and save to variable
Expected output :
welcome
/mnt/c/Users/Administrator
test
Press any key to continue . . .
CodePudding user response:
@echo off
title This is c9
echo welcome
for /f "usebackq delims=" %%i in (`
bash -c 'wslpath -a "C:\Users\Administrator"'
`) do set currentdir=%%i
echo %currentdir%
echo test
pause
CodePudding user response:
Not entirely sure but you could use %~dp0
which is a built in variable which displays the current directory. You can use cd
to change the current directory and let it be shown thrown %~dp0