Occasionally, I need to check every server and workstation on my network for a particular file or process. This task takes a long time because we have a lot of machines. In addition, performing such a search uses valuable network bandwidth and ruins my computer's performance. I decided that a better method was to have each machine check itself and report any results to me.
First, create on a server a share called \\MyServer\NewShare that has read and write access for the Everyone group. You must use a server because Windows 2000 Professional and Windows NT Workstation's 10-user limits will create a problem. Next, add the share name to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\NullSessionShares REG_MULTI_SZ registry entry. Perform this step manually so that you don't overwrite existing settings. A null session share is necessary to let the local System account that the scheduler service uses connect over the network to remote shares.
Create two directories named \\MyServer\NewShare\Tools and \\MyServer\NewShare\Results in the share. Give the Tools directory Everyone:R permissions and the Results directory Everyone:RW permissions. If you don't set the Tools directory to read-only, anyone connected to your network can change the directory's contents.
In the \\MyServer\NewShare\Tools directory, create the batch file
dir /s /b c:\FileToFind.txt > \MyServer\NewShare\Results%COMPUTERNAME%.txt
On all the computers you want to check, schedule the command
After this command runs, you'll have a list in the \\MyServer\NewShare\Results\ directory of all the computers on which the file FileToFind.txt exists.
You can modify the GetInfo.bat file to administer or analyze almost any process that takes a while to run. For example, I have a program that does a bit-by-bit cyclical redundancy check (CRC) of 10GB of data and publishes any errors in my Results directory. However, you need to be careful because the GetInfo.bat file might cause a disaster if you use it incorrectly. For example, I used a similar batch file to search for and delete a file on all my company's servers—imagine what could have gone wrong if I had deleted an important file.
To run the check at 12:00 on all the computers in your domain, use the code
('net view ^| findstr \ ') do at \\%i 12:00
Don't forget to use double percent signs (i.e., %%) in batch files.
To organize into one file all the FileToFind.txt entries in the \\MyServer\NewShare\Results\ directory, use the command
\\MyServer\NewShare\Results *.txt > c:\all.txt