locked
Copying a file to Multiple computers RRS feed

  • General discussion

  • I'm new to this and I know this has been asked many times but I need to Copy a file to multiple computers on a domain.

    I want to copy the file to the Public desktop on all computers. I tried this (see below) but got this error Any Idea???

    for /f %%a in (C:\Users\HULK\Desktop\copyfile\Computers.txt) do copy /y \\C:\Users\HULK\Desktop\copyfile\GAMMA.txt\\%%a\c$\Users\Public\Desktop
    %%a was unexpected at this time.

    • Changed type Bill_Stewart Monday, April 30, 2018 9:25 PM
    • Moved by Bill_Stewart Monday, April 30, 2018 9:25 PM User should not be trying to script this
    Thursday, February 22, 2018 4:16 PM

All replies

  • Use Group Policy preferences rather than trying to script it.

    -- Bill Stewart [Bill_Stewart]

    Thursday, February 22, 2018 4:24 PM
  • Thanks for your reply Bill but I don't have access to Group Policy that's why I'm going with this option.

    Thursday, February 22, 2018 4:55 PM
  • Then I recommend contacting your system administration team to set this up. There are multiple problems with trying to script this:

    • Firewall can prevent connection to remote computers
    • You must (usually) be a member of local Administrators group on all remote computers to copy files to Public desktop
    • Offline/remote VPN computers don't get the file copy and can cause script to hang
    • What happens when you need to distribute newer version of file? Above problems all over again
    • Other possible problems (these are just a few off the top of my head)

    Don't script it. Get your group policy admin to distribute.


    -- Bill Stewart [Bill_Stewart]

    Thursday, February 22, 2018 5:06 PM
  • foreach($computer in $computers){ Copy <localfile> \\$computer\c$\folder }

    Don't use batch.  It is obsolete and much harder to use.  Learn PowerShell.

    %% is not valid at a prompt.  It only works in a batch file.  At a prompt use only one %


    \_(ツ)_/


    • Edited by jrv Thursday, February 22, 2018 5:41 PM
    Thursday, February 22, 2018 5:40 PM
  • Still has same problems I mentioned previously.

    This should be done via Group Policy rather than a script (even if that script is PowerShell).


    -- Bill Stewart [Bill_Stewart]

    Thursday, February 22, 2018 5:41 PM
  • Still has same problems I mentioned previously.

    This should be done via Group Policy rather than a script (even if that script is PowerShell).


    -- Bill Stewart [Bill_Stewart]

    Yes.  It is the preferred method.


    \_(ツ)_/

    Thursday, February 22, 2018 5:42 PM
  • Thanks for all the input I will consult with my Sys Admins.
    Friday, February 23, 2018 4:56 PM