Solved VBScript to search file & log output if file DOESN'T exist

February 7, 2012 at 22:34:23
Specs: Windows XP
Hi All,

First of all thank you for reading my post. Recently Razor2.3 really helped me in creating batch file to disable windows service it was very helpful and I am back with another request to make my daily job more automated.

0. Every run should display date time and append log...
1. Ping 500 remote computers listed under computerlist.txt and
2. Use VBScript to search for file under C:\temp\abc.txt on remote pc if it's online
3. If file doesn't exist then have output in logfile to notify us (most important)

We can also have some advanced option of using xcopy to copy 15MB file on remote pc but I wasn't sure about result if remote pc shutdown in between copy or can we use something like bits admin?

If using xcopy is too much then can always start manual copying of file over network.

I have got below code which only works with single pc and does echo if file exist:
( Ref:

strComputer = "atl-fs-01"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService. _
ExecQuery("Select * From CIM_DataFile Where Name = 'C:\\Scripts\\Test.vbs'")

If colFiles.Count = 0 Then
Wscript.Echo "The file does not exist on the remote computer."
Wscript.Echo "The file exists on the remote computer."
End If


See More: VBScript to search file & log output if file DOESNT exist

Report •

February 8, 2012 at 08:58:28
✔ Best Answer
I don't wanna do a VBScript today. Have a(n untested) batch:
for /f %%a in (someList.txt) do (
  if not exist \\%%a\c$ (>>out.txt echo Failed to access: %%a) else (
    if not exist \\%%a\c$\temp\abc.txt (
      >>out.txt echo Copying to: %%a
      md \\%%a\c$\temp
      copy abc.txt \\%%a\c$\temp\abc.txt

EDIT: Requires the hidden admin shares, so I'm assuming you haven't killed them and you're not running the Home versions of Windows.

How To Ask Questions The Smart Way

Report •

February 8, 2012 at 18:30:39
Thanks Razor2.3 once worked exactly as required....

any idea how can I improve performance since it's taking too long even to ping 100 machines....

Report •

February 9, 2012 at 10:40:49
It's hard to know where the bottleneck is, but you could probably double your performance by cutting the list in half, and running the script on each half at the same time.

How To Ask Questions The Smart Way

Report •

Related Solutions

February 9, 2012 at 17:26:46
Yes.. no problem thank you.... I have already divided 1000 into 500-500..

I have noticed it was taking too much time to figure whether machine was online.. so I am using below steps for quick result..

1. Use VBscript to see which machine online...output.log
2. Run batch to check missing file on ONLY online machines from output.log ...Missingfile.log

Thanks for all your efforts in understanding and answering queries...


Report •

Ask Question