2011-12-15 105 views
0

我有一個命令incmd version產生以下輸出命令抓取列信息

All Rights Reserved. 
This Software is protected by U.S. Patent Numbers 5,794,246; 6,014,670; 6,016,50 
1; 6,029,178; 6,032,158; 6,035,307; 6,044,374; 6,092,086; 6,208,990; 6,339,775; 
6,640,226; 6,789,096; 6,820,077; 6,823,373; 6,850,947; 6,895,471; 7,117,215; 7,1 
62,643; 7,254,590; 7,281,001; 7,421,458; 7,496,588; 7,523,121; 7,584,422; 7,720, 
842; 7,721,270; and 7,774,791, international Patents and other Patents Pending. 

Version: 9.1.0 HotFix2 
Build: 1668 - 2011-Sep-02 
Command ran successfully. 

我想獲取9.1.0出來。到目前爲止使用findstr "Version"我只得到Version: 9.1.0 HotFix2有沒有一種方法可以提取列信息?

注意:不使用任何第三方工具。(anytool可用默認Windows是罰款)

回答

1

您可以使用for來標記該輸出:

for /f "tokens=2, delims= " %v in ('incmd version ^| findstr Version') do @set Version=%v 
echo %Version% 

help for瞭解命令及其選項的詳細說明。

請注意,如果你是在一個批處理文件中使用這個(我假定在第一,但顯然情況並非如此),你必須加倍在for變量百分號:

for /f "tokens=2, delims= " %%v in ('incmd version ^| findstr Version') do @set Version=%%v 
echo %Version% 
+0

它給我`%% v在這個時候是意想不到的.` – Ricky 2011-12-15 10:58:02