Report required on all servers if file was created

Posted on 2011-02-15
Last Modified: 2012-06-21
Hello Experts,
We currently have 100+ server in the network and on each a scheduled tasks runs everynight which compresses certain files (legacy application db files). If db files are not locked or used at the time it is compressed the file size ranges from 10MB-1GB otherwise its locked or being used the compressed output is just 1KB.
What i wanted is that to create a batch file ...
1.0 Which checks the file size on each server.
2.0 Records only the server which has 1KB file.
3.0 Outputs to a text file.
      sample content in the text file
      \\<Server4>\App\DComp\ IS ONLY 1KB.

Can you please at least show me or suggest some links to read as to how or where to start? I'm a newbie to programming (e.g. VB, etc...)
Question by:jsuanque
  • 3
  • 2

Expert Comment

ID: 34902966
small suggestion remove the archive option from all files using attrib . -a any new file added or modifed should have the archive option so if you run attrib . | find "A " you will get the list of modified files
LVL 65

Accepted Solution

RobSampson earned 125 total points
ID: 34902983
Hi there,

Try this code.


Set objFSO = CreateObject("Scripting.FileSystemObject")

strServers = "servers.txt"
' In the following file, <SERVER> will be automatically replaced with each server read from the file
strFile = "\\<SERVER>\App\DComp\"
strOutput = "smallfiles.txt"

Set objOutput = objFSO.CreateTextFile(strOutput, True)
Set objFile = objFSO.OpenTextFile(strServers, 1, False)
While Not objFile.AtEndOfStream
	strServer = objFile.ReadLine
	If Ping(strServer) = True Then
		strRemoteFile = Replace(strFile, "<SERVER>", strServer)
		If objFSO.FileExists(strRemoteFile) = True Then
			If objFSO.GetFile(strRemoteFile).Size < 2048 Then
				objOutput.WriteLine strRemoteFile & " is less than 2K"
			End If
			objOutput.WriteLine "File not found: " & strRemoteFile
		End If
		objOutput.WriteLine strServer & " is offline."
	End If

MsgBox "Done. Please see " & strOutput

Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
		Ping = False
	End If
End Function

Open in new window


Author Comment

ID: 34903117
Hello Waseems/RobSampson,
Definitely will try your suggestion...but at the moment, were advised to evacuate the office because of Cyclone warning :-)

Will get back hopefully tomorrow.
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

LVL 65

Expert Comment

ID: 34903225
Yikes....that doesn't sound like fun!

Good luck.

Author Closing Comment

ID: 35152829
Thanks Rob.My apologies for the delay.
LVL 65

Expert Comment

ID: 35152836
No problem. Thanks for the grade.



Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question