Copy a directory on active hosts

Hi all,

I need to copy a directory on all the machines on a specific LAN (192.168.0.0/24), but then again the IP are set via DHCP so I don't know what addresses are assigned at a given point in time.

Also, hosts are not up at the same time. Some of them run by night, others by day etc...

Therefore I want to write a script (batch or vbs) that would do the following :
ping all the available addresses from that subnet (from 1 to 254)
if the ping test is positive, checks if "destination path" doesn't exists and then copy "Source Dir" to \\192.168.0.x\C$\Path...
if the ping test is negative, puts the ip 192.168.0.x into a text file like retry.txt
then start from the top, but using the ips from the file retry.txt this time.

Then I'd run that script as a task, like every 12h, and in the long term all the hosts from that subnet would have their dirs updated.

Hope I am making sense ...

Thank you
fletcher_lAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StinkyPeteCommented:
This seams a long way round, do I guess right that your intent is consealment from the userbase?

Have you considered using Robocopy from the local machines at startup/logon/logoff?

Or redirect folders from the local client machine to a server share?
mmarx82Commented:
Is this on a domain, if so why not setup Group Policy to run the copy script on logon and/or logoff of the user?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
heideldCommented:
I can help with the ping all IP's on the subnet and the out pu of who is up and down.  However, the retry list part seems like there will be room for error.  It might be better to add a txt file named with the current date  as a tag to the folder that is being copied.  Run the script multiple times throughout a 24 hour period and have a log generated as to the results.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

fletcher_lAuthor Commented:
That is proper thinking outside the box :D Thanks!
pine_nel1Commented:
Hi fletcher,

Wsh should be the way to go, (not bothering with a ping I would do something like this, not tested):

set wshshell=wscript.createobject("wscript.shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
on error resume next
n = 1
do unitil n = 255
'' you can write some funtion to ping but too lazy ... just checking path
if  FSO.FolderExists("\\192.168.0." & n &"\C$") then
if Not FSO.FolderExists("\\192.168.0." & n &"\C$\Path") then
FSO.CopyFolder "Source Dir", ("\\192.168.0." & n &"\C$\Path")TRUE
else
pcs = pcs & "192.168.0." & n & vbCrLf
end if
end if
n = n + 1
loop

Set readfil = FSO.OpenTextFile("c:\retry.txt", 1, False)
do while readfil.AtEndofStream = False
pc1=readfil.ReadLine

if Not FSO.FolderExists("pc1 &"\C$\Path") then
FSO.CopyFolder "Source Dir", (pc1 &"\C$\Path")TRUE
else
pcs = pcs & "192.168.0." & n & vbCrLf
end if
Loop
readfil.close

FSO.DeleteFile "c:\retry.txt"
Set writefil = FSO.createTextFile("c:\retry.txt", False )
writefil.Write(pcs)
writefil.Close


Thanks

Pine
pine_nel1Commented:
oops replace the second pcs = pcs & "192.168.0." & n & vbCrLf with pcs = pcs & pc1 & vbCrLf
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.