Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch File Transfer over wireless network  (Read 8519 times)

0 Members and 1 Guest are viewing this topic.

wandavan

    Topic Starter


    Starter

    Batch File Transfer over wireless network
    « on: May 26, 2008, 02:04:23 PM »
    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 ?

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Batch File Transfer over wireless network
    « Reply #1 on: May 26, 2008, 04:31:54 PM »
    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.  8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    blastman



      Hopeful

      Re: Batch File Transfer over wireless network
      « Reply #2 on: May 27, 2008, 04:18:27 AM »
      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.

      Blastman, you are the man. Thank You Very Much!!!!!!!!!



      wandavan

        Topic Starter


        Starter

        Re: Batch File Transfer over wireless network
        « Reply #3 on: June 09, 2008, 09:41:48 PM »
        thank you guys for your help, I haven't tried it yet but will give it a run this week.

        cheers.

        DaveLembke



          Sage
        • Thanked: 662
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 10
        Re: Batch File Transfer over wireless network
        « Reply #4 on: June 09, 2008, 11:38:28 PM »
        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.

        wandavan

          Topic Starter


          Starter

          Re: Batch File Transfer over wireless network
          « Reply #5 on: June 12, 2008, 02:21:33 PM »
          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
          Loop

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: Batch File Transfer over wireless network
          « Reply #6 on: June 12, 2008, 03:44:13 PM »
          Quote
          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

           8)
          The true sign of intelligence is not knowledge but imagination.

          -- Albert Einstein

          wandavan

            Topic Starter


            Starter

            Re: Batch File Transfer over wireless network
            « Reply #7 on: June 12, 2008, 07:43:28 PM »
            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

            ???

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: Batch File Transfer over wireless network
            « Reply #8 on: June 13, 2008, 03:18:33 AM »
            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

             8)
            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein