【发布时间】:2017-10-22 17:51:04
【问题描述】:
我是新来的,很抱歉我的英语和帖子中的错误。
我需要帮助在批处理文件中设置变量 -> 并不像你想象的那么容易。 ..我的批处理文件中的示例:
rem set shortcut for long pc name
set pc1=LongNameOfMyPcNo.1
set pc2=LongNameOfMyPcNo.2
set pc3=LongNameOfMyPcNo.3
rem now, user can type "pc1" and in compmgmt line he get long name
set /p pc=type shortcut name
rem in next line i want get compmgmt.msc /computer:\\LongNameOfMyPcNo.1
compmgmt.msc /computer:\\%pc%
但只有我得到的是 compmgmt.msc /computer:\pc1
所以,我的问题是设置不起作用(或者我使用它不好),doskey,setlocal.. 也不起作用。
我不想使用选择和错误级别,因为我说的是 600 台计算机。所以我需要创建一个“小型”数据库,但我想在 txt (.bat) 中完成
【问题讨论】:
-
使用
compmgmt.msc /computer:\\!%pc%!并启用延迟扩展。见this answer
标签: database batch-file cmd set