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

Author Topic: Batch file to copy files from server location to pc's on domain  (Read 39527 times)

0 Members and 1 Guest are viewing this topic.

wonkydonk

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Unknown
    Batch file to copy files from server location to pc's on domain
    « on: January 25, 2012, 06:17:22 AM »
    Hi all

    hope someone can help, i have written a batch file that copies a number of files from a server location into specific folders on windows. i need help in finding a way to run that batch file on a list of PCs that are one the domain. i can across this thread on here

    http://www.computerhope.com/forum/index.php?topic=85837.0 but i couldn't find anything else.

    also in batch file is there a way to copy the files into all preexisting profiles on computer.

    thanks for any help

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Batch file to copy files from server location to pc's on domain
    « Reply #1 on: January 25, 2012, 12:04:29 PM »
    Sorry, I can't help.  :(
    Later, after this project, you may want to look at PowerShell:
    http://technet.microsoft.com/en-us/scriptcenter/dd742419
    Microsoft is wants everybody to try PowerShell for non-trivial teaks.

    wonkydonk

      Topic Starter


      Rookie

      • Experience: Beginner
      • OS: Unknown
      Re: Batch file to copy files from server location to pc's on domain
      « Reply #2 on: January 26, 2012, 01:17:29 AM »
      Code: [Select]
      @echo off
      rem templatetest3v2.BAT transfers all files in all subdirectories of
      rem the source drive or directory (%1) to the destination rem drive or directory (%2)
      xcopy "\\gblonvdat001\groups\desktop support\NS&I templates\NewNSANDITemplate\nsandi Templates" "C:\Program Files\Microsoft Office\Templates\nsandi templates" /s /e /y
      xcopy "\\gblonvdat001\groups\desktop support\NS&I templates\NewNSANDITemplate\Toolbar add-ins\nsandiToolbars.dot" "C:\Program Files\Microsoft Office\Office12\STARTUP" /s /e /y
      xcopy "\\gblonvdat001\groups\desktop support\NS&I templates\NewNSANDITemplate\Default templates\Book1.xlsx" "C:\Program Files\Microsoft Office\Office12\XLSTART" /s /e /y
      xcopy "\\gblonvdat001\groups\desktop support\NS&I templates\NewNSANDITemplate\Default templates\Normal.dotm" "C:\Program Files\Microsoft Office\Templates" /s /e /y
      xcopy "\\gblonvdat001\groups\desktop support\NS&I templates\NewNSANDITemplate\Default templates\blank.potx" "C:\Program Files\Microsoft Office\Templates" /s /e /y
      xcopy "\\gblonvdat001\groups\desktop support\NS&I templates\NewNSANDITemplate\Quick Access Toolbar\PowerPoint.qat" "C:\Documents and Settings\Default User\Application Data\Microsoft\Office" /s /e /y
      xcopy "\\gblonvdat001\groups\desktop support\NS&I templates\NewNSANDITemplate\Quick Access Toolbar\Word.qat" "C:\Documents and Settings\Default User\Application Data\Microsoft\Office" /s /e /y
      if errorlevel 4 goto lowmemory
      if errorlevel 2 goto abort
      if errorlevel 0 goto exit
      :lowmemory
      echo Insufficient memory to copy files or
      echo invalid drive or command-line syntax.
      goto exit
      :abort
      echo You pressed CTRL+C to end the copy operation.
      goto exit
      :exit

      it seems to work OK, when i run it on the PC i am using, but what i need to do is run the batch file on about 100 PCs which are on a domain. i don't really want to go to all 100 machines and run the batch file. so was looking for a way to run the batch file on a list of remote PCs.

      the last 2 xcopy lines i need to paste the 2 files on all the profile that would be on that PC.
      hope that makes sense

      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: Batch file to copy files from server location to pc's on domain
      « Reply #3 on: January 26, 2012, 05:52:40 AM »
      it seems to work OK, when i run it on the PC i am using, but what i need to do is run the batch file on about 100 PCs which are on a domain. i don't really want to go to all 100 machines and run the batch file. so was looking for a way to run the batch file on a list of remote PCs.
      Isn't that what Group Policies and Login Scripts are for.

      wonkydonk

        Topic Starter


        Rookie

        • Experience: Beginner
        • OS: Unknown
        Re: Batch file to copy files from server location to pc's on domain
        « Reply #4 on: January 26, 2012, 05:57:10 AM »
        yah well, don't get me started on that. that's a whole different issue. and unable to do it that way.

        so was looking into a way of doing it with the batch file

        Geek-9pm


          Mastermind
        • Geek After Dark
        • Thanked: 1026
          • Gekk9pm bnlog
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 10
        Re: Batch file to copy files from server location to pc's on domain
        « Reply #5 on: January 26, 2012, 10:57:06 AM »
        Before going further... Can you execute even a simple batch file on all computers? You may need to send an email no every user asking them to start the Banach program manually. There is an issue about security and policy.

        Otherwise... look at this:
        Quote
        ...
        PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, complete with full interactivity for console applications, without having to manually install client software   ....
        http://technet.microsoft.com/en-us/sysinternals/bb897553

        wonkydonk

          Topic Starter


          Rookie

          • Experience: Beginner
          • OS: Unknown
          Re: Batch file to copy files from server location to pc's on domain
          « Reply #6 on: January 26, 2012, 01:51:56 PM »
          yes a batch file can be run on all computers. i just don't want to go to all the pc's.

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: Batch file to copy files from server location to pc's on domain
          « Reply #7 on: January 26, 2012, 04:44:12 PM »
          yes a batch file can be run on all computers. i just don't want to go to all the pc's.
          We have a communication problem. I meant can you run batch files on the remote PCs from you workstation using any kind of remote execution program.

          The link above is for PsExec, a non-Microsoft utility that does what you want.

          If you can use PsExec do do a simple job, then it could do all of what you want, if the group policy allows. Test it first on something very simple.

          wonkydonk

            Topic Starter


            Rookie

            • Experience: Beginner
            • OS: Unknown
            Re: Batch file to copy files from server location to pc's on domain
            « Reply #8 on: January 27, 2012, 01:37:43 AM »
            i'll give that a try.

            also the last to xcopy lines is to copy a file to a location on users profiles on machine. at the moment i have it going to default users however. i need to be copied to all currant users profiles on the machine, if that makes sense

            Geek-9pm


              Mastermind
            • Geek After Dark
            • Thanked: 1026
              • Gekk9pm bnlog
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: Batch file to copy files from server location to pc's on domain
            « Reply #9 on: January 27, 2012, 02:04:09 AM »
            What the OP is doing is, in effect, deployment of a Microsoft solution over a network. People write books on this subject. One expert is Adam Carter. He has developed and used tools for Windows. Here is a nice tutorial he has.
            Pilot and Deploy Windows 7

            Squashman



              Specialist
            • Thanked: 134
            • Experience: Experienced
            • OS: Other
            Re: Batch file to copy files from server location to pc's on domain
            « Reply #10 on: January 27, 2012, 05:33:27 AM »
            The link above is for PsExec, a non-Microsoft utility that does what you want.
            Microsoft has owned SysInternals for many years now.  Which makes Psexec a Microsoft utility.

            wonkydonk

              Topic Starter


              Rookie

              • Experience: Beginner
              • OS: Unknown
              Re: Batch file to copy files from server location to pc's on domain
              « Reply #11 on: January 27, 2012, 05:42:19 AM »
              i got psexec to work, just the part of coping files into existing peoples profile

              Geek-9pm


                Mastermind
              • Geek After Dark
              • Thanked: 1026
                • Gekk9pm bnlog
              • Certifications: List
              • Computer: Specs
              • Experience: Expert
              • OS: Windows 10
              Re: Batch file to copy files from server location to pc's on domain
              « Reply #12 on: January 27, 2012, 05:36:50 PM »
              Microsoft has owned SysInternals for many years now.  Which makes Psexec a Microsoft utility.
              Thanks for the heads-up.

              Squashman



                Specialist
              • Thanked: 134
              • Experience: Experienced
              • OS: Other
              Re: Batch file to copy files from server location to pc's on domain
              « Reply #13 on: January 27, 2012, 09:23:16 PM »
              Thanks for the heads-up.
              You realize the original link you posted for psexec says microsoft.com for the domain name.

              Geek-9pm


                Mastermind
              • Geek After Dark
              • Thanked: 1026
                • Gekk9pm bnlog
              • Certifications: List
              • Computer: Specs
              • Experience: Expert
              • OS: Windows 10
              Re: Batch file to copy files from server location to pc's on domain
              « Reply #14 on: January 27, 2012, 10:10:13 PM »
              You realize the original link you posted for psexec says microsoft.com for the domain name.
              Thank you again. Somehow I thought MS was praising the virtues of something other than  a MS product.  :-[

              mangolzy



                Rookie

                • Experience: Beginner
                • OS: Windows 7
                Re: Batch file to copy files from server location to pc's on domain
                « Reply #15 on: June 25, 2014, 07:43:04 AM »
                i have to reply to a two-year-old thread again!!

                BUT since i have tried with psexec, it seems to work out with .exe file but can i run a .bat file on a machine in distance??

                thanks a lot!!