1.

Solve : Batch File Transfer over wireless network?

Answer»

Hi please excuse me if I am asking a redundant question.

I would like to create a batch command from one central computer that transfers files from four computers that are on the same wireless network.

Some are using Vista and OTHERS XP. The batch command would check a specific directory every five seconds on each of the four wirelessly NETWORKED computers and if there are files present it would transfer them to its own local directory.

If this wasn't possible from the central computer, we could have a batch command running on each of the four wireless computers do the transfer from each to the central.

A related question also is can a batch command be made to perform a logon to the computer it needs to transfer the files from ?If you try doing this in batch, you'll either end up with a loop that continually sucks up CPU cycles or need prior knowledge of the incoming file name (or both). If you try doing this on the server, you'll find that VBScript is not multi-threaded and can only monitor one directory at a time.

One solution would be to have each local computer run a script to monitor a file CREATION event and copy the file to the server upon arrival.

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set fso = CreateObject("Scripting.FileSystemObject")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
& "Targetinstance ISA 'CIM_Datafile' and " _
& "TargetInstance.Drive = 'C:' And TargetInstance.Path= '\\temp\\'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent()
Select Case objLatestEvent.Path_.Class
Case "__InstanceCreationEvent"
fso.CopyFile objLatestEvent.TargetInstance.Name servername
End Select
Loop

The above script monitors the c:\temp directory for file creations. When a file is created, it is copied to the server. You need to change servername to something appropriate and to remember to double up on all backslashes in the select statement paths!

Hope this helps. Hi,

Sidewinder suggestion would indeed work, but I would have written a simple batch to map some drives to the remote machines and then check the folders for your files, if there copy them to the local server. I would have then scheduled the batch file to run every 1 minute or so, anymorethen that and the CPU would become over worked.

hope it helps.thank you guys for your help, I haven't tried it yet but will give it a run this week.

cheers.I agree with all above suggestions, but if you want a delay in the batch, you can use the Choice command with a timeout and goto to keep it in a loop. CPU overload is a definate problem as for as soon as the data is sent it may need to resend again. You also will overwork your drives possibly if data changes frequently.

The other situation you could face if if the network connection drops, it could lock up your batch. See it before with hard wired network transfers that bail because of conjestion and a timeout occurs in the batch.All this makes sense thanks. I did map a drive from the server on the notebook and changed the script to reflect the mapped drive but wasnt sure sure about the proper syntax to use. I also assumed that I was saving it as an htm file.

Bottom line is it did not work and I put it down to my lack of knowledge in VBScripts.

here's what the script looks like now, I did modify it some by adding and removing parenthesis:


Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set fso = CreateObject("Scripting.FileSystemObject")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
& "Targetinstance ISA 'CIM_Datafile' and " _
& "TargetInstance.Drive = 'c:' And TargetInstance.Path= '\\Photos\\'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent()
Select Case objLatestEvent.Path_.Class
Case "__InstanceCreationEvent"
fso.CopyFile objLatestEvent.TargetInstance.Drive = Z:\\Images\\transfers\\
End Select
LoopQuote

fso.CopyFile objLatestEvent.TargetInstance.Drive = Z:\\Images\\transfers\\

Any reason you changed .Name to .Drive? The equal symbol is invalid in this context. If the Z drive is mapped you don't need double backslashes (the double backslashes are unique to the query); the output location can be treated as a local drive:

Code: [Select]fso.CopyFile objLatestEvent.TargetInstance.Name Z:\Images\transfers\

But you can use UNC notation for the output location if you prefer:

\\computername\Z$\images\transfers


Not knowing what I was doing I made those changes

the script fails at line: 14 char: 57 error: expected end of statement code: 800A0401, vbscript compilation error.

It seems to have a problem with the Z, but that is the mapped drive. The map name is Images so I removed that name from the path since the mapping put us into that folder, however it made no difference.

I tried it also using the unc but I got a syntax error at char 58

I guess some days are better than others. This should fix you right up. Sorry for any confusion.

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set fso = CreateObject("Scripting.FileSystemObject")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
& "Targetinstance ISA 'CIM_Datafile' and " _
& "TargetInstance.Drive = 'c:' And TargetInstance.Path= '\\Photos\\'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent()
Select Case objLatestEvent.Path_.Class
Case "__InstanceCreationEvent"
fso.CopyFile objLatestEvent.TargetInstance.Drive, "Z:\\Images\\transfers\\"
End Select
Loop

Save script with a vbs extension and run from the command line as
wscript scriptname.vbs



Discussion

No Comment Found