插入输入到一个可变 [英] Insert Input into a variable
本文介绍了插入输入到一个可变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作的乐趣和学习批处理脚本。
我已经设置了多个,选项,例如FINT IP地址,MAC地址...等等。
问题是,我不能找出如何我可以插入这两条线的输出到变量。
FOR / F在有usebackq跳过= 1%% F(`WMIC COMPUTERSYSTEM得到name`)做?
FOR / F在有usebackq跳过= 1%% F(`WMIC COMPUTERSYSTEM得到domain`)做?
所以我可以使用输出一句话; </ P>
您的DNS名称是%dns_name_output%和您的域名%domain_name_output%。
解决方案
这适用于使用WMIC没有任何嵌入奇空格或CR的。
关闭@echo
FOR / F令牌= 2 delims =&LT;&gt;中%%一个在('WMIC COMPUTERSYSTEM得到名称/格式:htable ^ |找到隐藏)并设置NAME = %%一个
FOR / F令牌= 2 delims =&LT;&gt;中%%一个在('WMIC COMPUTERSYSTEM得到域/格式:htable ^ |查找隐藏)并设置DOM = %%一个
回声%名称%,%DOM%
暂停
I'm working on a batch script for fun and learning.
I've set up multiple choises, e.g Fint IP address, MAC address...and so on. The problem is that i can't find out how i can insert the output of those two lines into variables.
for /f "usebackq skip=1" %%f in (`wmic COMPUTERSYSTEM get name`) do ???
for /f "usebackq skip=1" %%f in (`wmic COMPUTERSYSTEM get domain`) do ???
So I can use the output in a sentence like;
Your DNS-name is %dns_name_output% and your domain is %domain_name_output%.
解决方案
This works using wmic without any odd spaces or CRs embedded.
@echo off
for /f "tokens=2 delims=<>" %%a in ('wmic COMPUTERSYSTEM get name /format:htable^|find "hidden"') do set "name=%%a"
for /f "tokens=2 delims=<>" %%a in ('wmic COMPUTERSYSTEM get domain /format:htable^|find "hidden"') do set "dom=%%a"
echo "%name%,%dom%"
pause
这篇关于插入输入到一个可变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文