Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


February 2003

Find a File

RSS
Subscribe to Windows IT Pro | See More Task Automation Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

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

Rem GetInfo.bat
dir /s /b c:\FileToFind.txt > \MyServer\NewShare\Results%COMPUTERNAME%.txt
exit

On all the computers you want to check, schedule the command

at \\AnyComputer 12:00
 \\MyServer\NewShare\Tools GetInfo.bat

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

for /f "delims=\ " %i in
 ('net view ^| findstr \ ') do at \\%i 12:00
 \\MyServer\NewShare\Tools GetInfo.bat

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

findstr "FileToFind.txt" 
  \\MyServer\NewShare\Results  *.txt > c:\all.txt

End of Article



Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
CES 2009: Ballmer Announces Windows 7, Windows Live, Live Search Milestones

During his first-ever Consumer Electronics Show (CES) 2009 keynote address last night in Las Vegas, Microsoft CEO Steve Ballmer announced the pending public availability of a feature-complete Windows 7, the final version of Windows Live Essentials, and ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

Where is Microsoft NetMeeting in Windows XP?

...


Task Automation Whitepapers Essential Guide to E-discovery and Recovery for Microsoft Exchange

Continuous Data Protection and Recovery for Microsoft Exchange

Protecting (You and) Your Data with Exchange Server 2007

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing