『楼 主』:
求助,帮忙编写一个脚本
使用 LLM 解释/回答一下
我想实现的功能是:\
查找 每台计算机的hots文件大小是否为指定的大小,如果是就记录计算机名,如果不是就不记录。
现在我手上有个txt文件,里面每一行是一个计算机名假设定义它有100行,也就是100台计算机。
首先我想通过 for 指令来 抓取TXT文件中的 计算机 名,保存到一个变量中,然后实现 自动映射 net use K: \\计算机名\c$\windows\system32\etc
(因为本人不太会用 for 指令,所以不知道怎么提取)
判断是否映射成功, 如果 不成功 则把 值 N 赋给一个变量,
成功了 就继续 执行下面的操作。
dir K:\hots >> d:\1.txt (查看 hots文件的信息,记录到1.txt文件中)
然后再次用 for 来分析 txt文本中的 文件大小 部分, 如果 该HOTS文件大小为 750K , 则记录该计算机名。
到最后 生成一个文本。 该文本的格式为
计算机 (这个只显示计算机名,表示该hots文件大小为要对比的大小)
计算机名,N (这个表示 该计算机映射未成功)
>和 >>的用法,刚好 一个覆盖,一个追加。。
请高手帮我编写这个 批处理 。谢谢!
What I want to implement is: Find whether the size of the hots file of each computer is the specified size. If it is, record the computer name; if not, do not record.
Now I have a txt file, and each line in it is a computer name. Suppose there are 100 lines, that is, 100 computers.
First, I want to use the for command to grab the computer names in the TXT file and save them to a variable, and then implement the automatic mapping net use K: \\computer name\c$\windows\system32\etc
(Because I don't know how to extract it very well, I don't know how to use the for command)
Judge whether the mapping is successful. If it is not successful, assign the value N to a variable.
If it is successful, continue to perform the following operations.
dir K:\hots >> d:\1.txt (view the information of the hots file and record it to the 1.txt file)
Then use for again to analyze the file size part in the txt text. If the size of the HOTS file is 750K, record the computer name.
In the end, a text is generated. The format of this text is
Computer (this only shows the computer name, indicating that the size of the hots file is the size to be compared)
Computer name, N (this means that the mapping of the computer is not successful)
> and >> are used, just one overwrites and the other appends.
Please help me write this batch processing. Thank you!
|