简体   繁体   中英

batch command output to variable as text

cscript //nologo versioninfo.vbs Kernel Kernel\bin\Release\Kernel.exe

This script returns me a version of my Kernel file. Let's say 3.11

Now I want to create a directory containing that 3.11.

set version=cscript //nologo versioninfo.vbs Kernel Kernel\bin\Release\Kernel.exe

set destination=\MyProgram(%version%)

if not exist %destination% mkdir %destination%

but it doesn't create it with the name

MyProgram(3.11)

as expected but creates as

MyProgram(cscript //nologo versioninfo.vbs Kernel Kernel\\bin\\Release\\Kernel.exe)

So I need my cscript output set as a text so I could just insert it into my destination.

Solution:

cscript //nologo versioninfo.vbs Kernel Kernel\bin\Release\Kernel.exe > tmp
SET /p version= < tmp

Found the solution

cscript //nologo versioninfo.vbs Kernel Kernel\\bin\\Release\\Kernel.exe > tmp SET /p version= < tmp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM