中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-02 07:10
48,037 topics / 350,122 posts / today 2 new / 48,250 members
DOS批处理 & 脚本技术(批处理室) » How can I make a batch file execute according to the machine name??
Printable Version  955 / 4
Floor1 gzrjhxh Posted 2006-10-19 02:14
新手上路 Posts 4 Credits 16
I wrote a batch file and want it to run according to the machine's name. For example, machines starting with "A" won't run it, and machines starting with "Y" will. How can this be done using only batch processing, without any tools????
Floor2 yfd11 Posted 2006-10-19 04:56
初级用户 Posts 15 Credits 44
Would it be like this:
if %COMPUTERNAME:~0,1% == "A" goto :end
if %COMPUTERNAME:~0,1% == "Y" goto :执行体
others....
Floor3 lxmxn Posted 2006-10-19 07:07
版主 Posts 4,938 Credits 11,386

  Mm, the code from the poster above can solve the OP's problem exactly.
Floor4 gzrjhxh Posted 2006-10-20 02:30
新手上路 Posts 4 Credits 16
Thanks, everyone.. I also found a method myself, sharing it.. hehe...
echo %userdomain% | find /i "y" && goto y
Floor5 vkill Posted 2006-10-20 03:42
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Originally posted by gzrjhxh at 2006-10-20 02:30:
Thanks, everyone.. I also found a method myself, sharing it.. hehe...
echo %userdomain% | find /i "y" && goto y

Hehe, try it a few more times and you'll know this one's drawback
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023