-2

how to build command from variables, for examples buildcmd.bat

edit: need output as predfined command not execute it

@echo off
set /p VAR1=variables 1?:
set /p VAR2=variables 2?: 
echo python D:\myscript.py %VAR1% %VAR2%

output

C:\bin>buildcmd.bat
variables 1?: var=aaa
variables 2?: var=bbb
python D:\myscript.py var=aaa var=bbb
C:\bin>

expected

C:\bin>buildcmd.bat
variables 1?: var=aaa
variables 2?: var=bbb
C:\bin>python D:\myscript.py var=aaa var=bbb
FelixSFD
  • 6,052
  • 10
  • 43
  • 117
uingtea
  • 6,002
  • 2
  • 26
  • 40
  • It is unclear what you are asking. May [this answer](https://stackoverflow.com/questions/29857183/how-can-i-run-cmd-from-batch-file-and-add-text-to-line-without-executing/29887523#29887523) or [this one](https://stackoverflow.com/questions/23549048/is-there-anyway-to-have-preset-data-for-user-input-in-a-batch-file/23551029#23551029) solve your problem perhaps? – Aacini Jun 10 '17 at 15:55
  • Please do not vandalize your posts. Once you've posted a question, you have licensed the content to the Stack Overflow community at large (under the CC-by-SA license). If you would like to disassociate this post from your account, see [What is the proper route for a disassociation request?](http://meta.stackoverflow.com/questions/323395/what-is-the-proper-route-for-a-dissociation-request). – FelixSFD Jun 16 '17 at 15:28

2 Answers2

0

This should solve the issue.


@echo off
set /p VARS1=variables 1?:
set /p VARS2=variables 2?:

    echo %CD%^>python D:\myscript.py %VARS1% %VARS2%
  • You entered %VAR1% and %VAR2 instead of %VARS1% and %VARS2% in the python command.
0

If you

set /p VARS1=

Then perhaps it would be an idea to use %VARS1% as the parameter and not %VAR1%

Magoo
  • 77,302
  • 8
  • 62
  • 84