China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-02 21:40
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to display computer names that meet the requirements without duplicates? View 858 Replies 14
Original Poster Posted 2006-12-23 11:06 ·  中国 湖北 武汉 硚口区 电信
初级用户
Credits 20
Posts 8
Joined 2006-12-23 09:03
19-year member
UID 74345
Gender Male
Status Offline
There are 200 machines. How can I do this:

After determining that the file c:\xx.exe does not exist,
display that computer name into the file d:\a.txt
and the computer names must not be duplicated!! How should the batch file be written?

The requirement is to keep the computer names that meet the condition~
Floor 2 Posted 2006-12-23 12:08 ·  中国 福建 厦门 电信
初级用户
Credits 68
Posts 36
Joined 2006-12-20 15:31
19-year member
UID 74057
Gender Male
Status Offline
Floor 3 Posted 2006-12-23 12:14 ·  中国 北京 中国科学院研究生院
银牌会员
★★★
Credits 1,187
Posts 555
Joined 2006-12-21 07:35
19-year member
UID 74129
Gender Male
Status Offline
Floor 4 Posted 2006-12-23 12:16 ·  中国 湖北 武汉 硚口区 电信
初级用户
Credits 20
Posts 8
Joined 2006-12-23 09:03
19-year member
UID 74345
Gender Male
Status Offline
If you write it like that, then a.txt can only keep 1 computer name!!!!!!!!!!!!!!!!
I need to save all computer names that meet the condition~
Floor 5 Posted 2006-12-23 12:17 ·  中国 湖北 武汉 硚口区 电信
初级用户
Credits 20
Posts 8
Joined 2006-12-23 09:03
19-year member
UID 74345
Gender Male
Status Offline
IF EXIST C:\"Program Files\Globallink" (exit) ELSE (if exist \\games\log$\ATI\%userdomain%.txt (exit) else echo %userdomain%>\\games\log$\ATI\%userdomain%.txt)

Is this line correct?
It feels very wordy,, how can it be written more concisely?
Floor 6 Posted 2006-12-23 12:21 ·  中国 福建 厦门 电信
初级用户
Credits 68
Posts 36
Joined 2006-12-20 15:31
19-year member
UID 74057
Gender Male
Status Offline
Floor 7 Posted 2006-12-23 12:22 ·  中国 湖北 武汉 硚口区 电信
初级用户
Credits 20
Posts 8
Joined 2006-12-23 09:03
19-year member
UID 74345
Gender Male
Status Offline
Everything above is on one line~
Floor 8 Posted 2006-12-23 12:24 ·  中国 福建 厦门 电信
初级用户
Credits 68
Posts 36
Joined 2006-12-20 15:31
19-year member
UID 74057
Gender Male
Status Offline
http://www.cn-dos.net/forum/viewthread.php?tid=18996&fpage=1&highlight=%E9%87%8D%E5%A4%8D
This thread talks about how to determine whether line contents are identical and handle them accordingly~~ I still haven't fully figured it out.. you can refer to it.

echo %userdomain% >>D:\a.txt This way you can write in all computer names
Floor 9 Posted 2006-12-23 12:32 ·  中国 湖北 武汉 硚口区 电信
初级用户
Credits 20
Posts 8
Joined 2006-12-23 09:03
19-year member
UID 74345
Gender Male
Status Offline
I know, but with your line, if it runs multiple times,, there will be duplicate computer names in a.txt!!!
Floor 10 Posted 2006-12-23 12:33 ·  中国 福建 厦门 电信
初级用户
Credits 68
Posts 36
Joined 2006-12-20 15:31
19-year member
UID 74057
Gender Male
Status Offline
..thinking..

[ Last edited by fjcyz on 2006-12-22 at 11:42 PM ]
Floor 11 Posted 2006-12-23 12:36 ·  中国 福建 厦门 电信
初级用户
Credits 68
Posts 36
Joined 2006-12-20 15:31
19-year member
UID 74057
Gender Male
Status Offline
Using the contents in a text file to determine whether there are duplicates is harder... waiting for an expert.~~

But if each machine generates one file after running the batch file, then using a batch file to determine whether files are duplicated is much simpler.
Floor 12 Posted 2006-12-23 12:45 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
  The key to the problem is: how to obtain the computer names of the other machines on the network from one machine. Everything else is very simple. Since I don't have a networked environment to test in, I can't provide code for now.

  Also, in the OP's requirement, filtering duplicate computer names is very different from the solution in the thread pointed to by 8F; it can be implemented very easily with a findstr regex.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 13 Posted 2006-12-23 12:49 ·  中国 北京 中国科学院研究生院
银牌会员
★★★
Credits 1,187
Posts 555
Joined 2006-12-21 07:35
19-year member
UID 74129
Gender Male
Status Offline
Originally posted by noop at 2006-12-22 23:16:
If you write it like that, then a.txt can only keep 1 computer name!!!!!!!!!!!!!!!!
I need to save all computer names that meet the condition~



It is my fault , just mistyping a ">"

thanks!
Floor 14 Posted 2006-12-23 12:52 ·  中国 福建 厦门 电信
初级用户
Credits 68
Posts 36
Joined 2006-12-20 15:31
19-year member
UID 74057
Gender Male
Status Offline
I think what the OP has in mind should be:

Have each of the 200 machines run a batch file, and then write that batch file's report results into the shared machine Game.

Could the moderator write a batch file for this, so we can learn from it.
Floor 15 Posted 2006-12-23 12:58 ·  中国 广西 南宁 联通
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
If it's as the poster above said, change it to:
@echo off
if exist C:\xx.exe exit
echo %userdomain% >>network path......\a.txt
Forum Jump: