2016-11-02 73 views
0
cscript //nologo versioninfo.vbs Kernel Kernel\bin\Release\Kernel.exe 

此腳本返回我的內核文件版本。比方說3.11批處理命令輸出爲文本變量

現在我想創建一個包含3.11的目錄。

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

set destination=\MyProgram(%version%) 

if not exist %destination% mkdir %destination% 

,但它不使用名稱創建

MyProgram(3.11)

如預期而造成的

MyProgram(CSCRIPT // NOLOGO versioninfo.vbs內核 內核\ bin \ Release \ Kernel.exe)

所以我需要我的cscript輸出設置爲一個文本,所以我可以把它插入到我的目的地。

解決方案:

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

可能的[如何在Windows中的變量中獲取命令的結果]重複(http://stackoverflow.com/questions/108439/how-do-i-get-the-result-of-a-command -in-A-可變式窗口) – aschipfl

回答

0

實測溶液

CSCRIPT // NOLOGO versioninfo.vbs內核內核\ BIN \發佈\ KERNEL.EXE> TMP SET/P版本= < TMP

相關問題