+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
How do you do....it? Thread, Copying one file to multiple computers in Technical; Hi gang, Something's stopped me being clever this morning. I've got a shortcut file that I want to put on ...
  1. #1
    WithoutMotive's Avatar
    Join Date
    Feb 2006
    Location
    Wigan, UK
    Posts
    631
    Thank Post
    41
    Thanked 49 Times in 43 Posts
    Rep Power
    27

    Copying one file to multiple computers

    Hi gang,

    Something's stopped me being clever this morning.
    I've got a shortcut file that I want to put on admin users desktops. I've already written it into the logon script as a simple copy command from a network location to Documents and Settings\All Users\Desktop so tomorrow it won't be a problem.

    However, I'm impatient and want it there now.
    Can the copy command be used to run a batch now to copy this shortcut to the desktop of every admin computer currently on? Can it be done without using GP?

    Someone suggested somewhere that...

    Code:
    copy \\server\file.lnk "\\%computername%.mydomain.local\c$\Documents and Settings\All Users\Desktop\file.lnk"
    ... might work but it didn't.

  2. #2

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,532
    Thank Post
    1,341
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    youd need to have a list of all the computers in a text file

    and then do a for loop to loop through all the entries in the text file

    gimme a min ill knock up the exact syntax

  3. #3


    Join Date
    Oct 2006
    Posts
    3,414
    Thank Post
    184
    Thanked 356 Times in 285 Posts
    Rep Power
    149
    If you are running it in the local computers context.

    Code:
    copy \\server\file.lnk "%allusersprofile%\Desktop\file.lnk"

  4. #4


    Join Date
    Jul 2007
    Location
    Rural heck
    Posts
    2,662
    Thank Post
    120
    Thanked 433 Times in 352 Posts
    Rep Power
    126
    FOR %%A IN (pc1 pc2 pc3 etc etc) DO copy \\server\file.lnk "\\%%A.mydomain.local\c$\Documents and Settings\All Users\Desktop\file.lnk"

    The above might work, I don't have time to test it.

    With Powershell or VBS you should be able to do a script that reads the computernames from AD.

  5. #5
    sharkster's Avatar
    Join Date
    Nov 2007
    Location
    Middlesbrough
    Posts
    149
    Thank Post
    23
    Thanked 26 Times in 21 Posts
    Rep Power
    19
    this should work,

    xcopy \\server\file.lnk \\%computername%.mydomain.local\c$\DOCUME~1\ALLUSE ~1\DESKTOP\file.lnk

    or

    xcopy \\server\file.lnk \\%computername%\c$\DOCUME~1\ALLUSE~1\DESKTOP\file .lnk


    i don't normaly use the domaim.local
    if you use it in a batch file, dont think batch can take the spaces,

    edit - the website has put a space between alluse~1 on the top line and file.lnk on the 2nd line but there shouldnt be

  6. #6
    SteveBentley's Avatar
    Join Date
    Jun 2007
    Location
    Yorkshire
    Posts
    1,453
    Thank Post
    120
    Thanked 264 Times in 190 Posts
    Rep Power
    73
    Excel and its Fill Down option is quite handy for making batch files like that, copy and paste the lot into Notepad and find/replace on the tabs to get rid of the gaps.

  7. #7

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,777
    Thank Post
    960
    Thanked 1,378 Times in 842 Posts
    Blog Entries
    1
    Rep Power
    456
    Also remember you can use Group Policy Extenstions for this as well (free)

  8. #8
    rh91uk's Avatar
    Join Date
    Sep 2008
    Location
    UK
    Posts
    877
    Thank Post
    137
    Thanked 132 Times in 114 Posts
    Rep Power
    36
    I do this sometiomes frequently via a script I picked up ... I posted it in another thread.

    Try this script that I have used (attatched) which I use sometimes to patch remote machines.

    You'll need to add machines you want to deploy to a group - I use STRCCWorkstations (schoolname, workstation).

    You can add command line parameters too after you have specified the install file - Installing IE7 Silently is Simple… | So Joe... should help you.

    Hope it works! (it does here! ).

    Another note - if you have windows firewall on you need to make sure WMI is allowed as an exception - you can do it via GPO - but that's for another time...!
    You may be able to do something with it...


    rh91uk
    Attached Files Attached Files

  9. #9
    ricki's Avatar
    Join Date
    Jul 2005
    Location
    uk
    Posts
    1,477
    Thank Post
    20
    Thanked 164 Times in 157 Posts
    Rep Power
    52
    Hi

    I dont know if you could do this but it might be easier.

    Create a share on a server and assign the admin users read permission on the share and the ntfs permissions.

    Copy the short cuts or icons in the share

    Now create a group policy that will only apply to one test user of admin and call it redirect desktop.

    Now edit the gpo and set the path to the share, set the grant users exclusive access to disable, move content of desktop to disable, policy removal behavior to restore content.

    Find a admin computer and run gpupdate /force /boot. This will update group policy and reboot the pc.

    Log on as the test user and you should get the normal icon from all users on the machine and the redirected desktop.

    The only problem with this is if users have been storing things on the desktop which I dont allow because I don't backup individual pcs and only backup the servers.

    Just an idea.

    Richard

  10. #10
    WithoutMotive's Avatar
    Join Date
    Feb 2006
    Location
    Wigan, UK
    Posts
    631
    Thank Post
    41
    Thanked 49 Times in 43 Posts
    Rep Power
    27
    Thanks to all. I'll give a few of those options a go.

  11. #11

    Join Date
    Jan 2010
    Location
    Pittsburgh
    Posts
    13
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    10

    PSExec or Group Policy

    Sometimes when I want to be quick and dirty about something i'll use psexec. In your case i'd just have a batch file located on a network share that runs the copy command. Then i'd create a text file that contains a list of the machines i want to hit. I usually use a program called lookatlan to scan the network and do an export. Then i'll just execute this command psexec @c:\computer.txt -u domain\user -d "\\server\share\copy.bat"

    There actually is away to use group policy to place a shortcut on a desktop as well. Currently I'm using Win 7 and if you are using you GPO Management you can goto Computer Config/Preferences/Windows Settings/Files Here just do a file replace of the ICO image for your shortcut. Then go to Config/Preferences/Windows Settings/Shortcuts then just create the shortcut you want.

  12. #12

    Join Date
    Feb 2010
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Curious about the PSEXEC option

    Asanders,
    What copy command do you use in your batch file? I understand the @file option. I dont understand how a remote copy command will copy the proper file to all of the computers in the computer.txt file. Dont you have to specify the file to be copied and the destination in the copy command?

    copy c:\folder\test.txt "\\remote computer\folder"

    How does the computer.txt file replace the remote computer?

  13. #13

    Join Date
    Jan 2010
    Location
    Pittsburgh
    Posts
    13
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    10

    PSEXEC Example

    Think of PSExec like this it allows you to remotely execute a command on a machine. In this case we just want to run a batch file. I'll try and create a step by step example for you

    Step 1. Create batch file called copy.bat and place it on a network share that can be accessed by everyone. ie \\server\share
    Step 2. Place the shortcut you want in the same network share as copy.bat ie \\server\share\Shortcut.lnk
    Step 3. Edit copy.bat and type this
    copy "\\server\share\Shortcut.lnk" "C:\Documents and Settings\All Users\Desktop\"
    Step 4. Create a text file called computers.txt in the root of your C:\ and in that file just list your computers you want this batch file to run on.
    ie. Computer1
    Computer2
    Computer3
    Computer4
    **Note The reason we are creating this text file is because we want a list of computer names and psexec will execute the batch file on every computer that is listed in that text file.
    Step 5. In CMD type this "psexec @C:\computers.txt -u domain\UserWithAdminRights -p Pa$$Word -d "\\server\share\copy.bat"

    **Note that I added this -d because I just want the batch file to run and disconnect. Otherwise you will see the batch file run on each computer and well that can take forever.

  14. Thanks to asanders from:

    mwbutler (6th May 2014)

  15. #14

    Join Date
    Feb 2010
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Talking

    Asanders,
    Thank you for the information. I knew psexec would be able to copy the files I needed across the network but I could not figure out how to do it. This makes my life so much easier. Thanks for your help. It is working like a charm.

  16. #15

    Join Date
    Aug 2012
    Posts
    1
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by asanders View Post
    Think of PSExec like this it allows you to remotely execute a command on a machine. In this case we just want to run a batch file. I'll try and create a step by step example for you

    Step 1. Create batch file called copy.bat and place it on a network share that can be accessed by everyone. ie \\server\share
    Step 2. Place the shortcut you want in the same network share as copy.bat ie \\server\share\Shortcut.lnk
    Step 3. Edit copy.bat and type this
    copy "\\server\share\Shortcut.lnk" "C:\Documents and Settings\All Users\Desktop\"
    Step 4. Create a text file called computers.txt in the root of your C:\ and in that file just list your computers you want this batch file to run on.
    ie. Computer1
    Computer2
    Computer3
    Computer4
    **Note The reason we are creating this text file is because we want a list of computer names and psexec will execute the batch file on every computer that is listed in that text file.
    Step 5. In CMD type this "psexec @C:\computers.txt -u domain\UserWithAdminRights -p Pa$$Word -d "\\server\share\copy.bat"

    **Note that I added this -d because I just want the batch file to run and disconnect. Otherwise you will see the batch file run on each computer and well that can take forever.
    I followed your instructions however on all of my workstation names it says

    \\workstation
    The filename, directory name, or volume label syntax is incorrect

    Am I supposed to add anything else to the computer.txt file?



SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. File copying at logon.
    By Bengaul in forum Scripts
    Replies: 8
    Last Post: 4th February 2008, 04:53 PM
  2. Logging on multiple computers.
    By gwendes in forum Network and Classroom Management
    Replies: 20
    Last Post: 13th November 2007, 12:56 AM
  3. copying a file without admin
    By strawberry in forum Windows
    Replies: 2
    Last Post: 20th September 2007, 10:23 AM
  4. File Copying
    By Kwyjibo in forum Scripts
    Replies: 15
    Last Post: 9th May 2007, 04:30 PM
  5. copying a file at logon
    By browolf in forum Windows
    Replies: 1
    Last Post: 18th October 2005, 05:26 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •