Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5371
  • Last Modified:

Need a batch script to check if a remote folder exists from a list of machines

Hi,

I need a batch script that will check to see if a remote folder exists based on a list of machines in a text file.  I will be running this script from my desktop and need to verify the existence of a folder on each of our servers.

For example, I'd like to verify that c:\windows\system32\test folder exists from a list of machines in machines.txt

Thanks!
0
windows7expert
Asked:
windows7expert
1 Solution
 
5g6tdcv4Commented:
0
 
windows7expertAuthor Commented:
I would also like it to output to another text file detailing the results of whether or not the folder exists on that specific machine.
0
 
Bill PrewCommented:
How about something like this.  Save as a BAT file and run from same folder as machines.txt.

@echo off
if exist "exists.txt" del "exists.txt"
for /F %%A in (machines.txt) do (
  if exist "\\%%A\C$\windows\system\test\" (
    echo %%A : FOUND >>exists.txt
  ) else (
    echo %%A : MISSING >>exists.txt
  )
)

Open in new window

~bp
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
pnormsCommented:
Are you using admin shares?
0
 
windows7expertAuthor Commented:
BP, that worked perfectly!
0
 
Bill PrewCommented:
Great, glad that helped.

~bp
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now