+ Post New Thread
Results 1 to 13 of 13
Windows Server 2000/2003 Thread, Copying files to multiple computers - Running the script once in Technical; I have written a batch script to copy a config file to multiple computers. Code: REM Copies the FuseCore Config ...
  1. #1
    networkingNut's Avatar
    Join Date
    Oct 2008
    Location
    Midlands
    Posts
    144
    Thank Post
    15
    Thanked 2 Times in 2 Posts
    Rep Power
    13

    Copying files to multiple computers - Running the script once

    I have written a batch script to copy a config file to multiple computers.

    Code:
    REM Copies the FuseCore Config File to the installation folder to ensure that the client software can locate the database on the Server.
    
    XCOPY "\\server\SYSVOL\domain\scripts\Zeitgeist Client\FuseCore.config" "C:\Program Files\OxBox\Zeitgeist AQA GCE German - 31d6f5c4-196f-4a1c-9a18-47d80a262a4d\" /Y
    At the moment I have deployed it as a start up script with the GPO to which the software relates. The only problem I can see with this, is the script will run every time the computer starts, which is not ideal. Is there a way to ensure that the script only runs once or is it a case of a manual job?

    I am on server 2003 with XP clients.

    Thanks
    nN

  2. #2

    Join Date
    Dec 2007
    Posts
    890
    Thank Post
    94
    Thanked 165 Times in 140 Posts
    Rep Power
    50
    Use IF EXIST command to check if a file/folder you are trying to copy over is already on the computer.

    You could always do it through Group Policy Preferences (Computer Configuration > Preferences > Windows Settings > Files) and then use Item Level Filtering to only apply if file/folder does not exist.
    Last edited by MYK-IT; 11th August 2011 at 01:37 PM.

  3. #3
    networkingNut's Avatar
    Join Date
    Oct 2008
    Location
    Midlands
    Posts
    144
    Thank Post
    15
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Quote Originally Posted by MYK-IT View Post
    Use IF EXIST command to check if a file/folder you are trying to copy over is already on the computer.

    You could always do it through Group Policy Preferences (Computer Configuration > Preferences > Windows Settings > Files) and then use Item Level Filtering to only apply if file/folder does not exist.
    The file does exist. The difference in the files is that the newer one, which I am trying to copy over includes the path to the database, which is on the server

    If you do a manual install this would be done as part of the normal installation wizard, but that would mean an individual install, which I am trying to avoid.

    I have even looked at editing the MSI with ORA but cant see where to add a new column or even what to call it. I have also asked tech support and they could not help

    Thanks
    nN

  4. #4

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,374
    Thank Post
    906
    Thanked 1,811 Times in 1,559 Posts
    Blog Entries
    12
    Rep Power
    468
    You could use Robocopy with the /mir switch. It will only then copy file when you update the source.

    You can use this code

    Code:
    robocopy.exe "\\server\SYSVOL\domain\scripts\Zeitgeist Client" "C:\Program Files\OxBox\Zeitgeist AQA GCE German - 31d6f5c4-196f-4a1c-9a18-47d80a262a4d" /mir
    You can extract robocopy from the Windows Server 2003 Resource Kit Tools. You dont have to install it on all clients, you can just host robocopy .exe on a share

  5. Thanks to FN-GM from:

    networkingNut (12th August 2011)

  6. #5

    jinnantonnixx's Avatar
    Join Date
    Mar 2011
    Location
    In the Calamatorium.
    Posts
    2,086
    Thank Post
    123
    Thanked 534 Times in 357 Posts
    Blog Entries
    2
    Rep Power
    336
    Put a call to run the script in the RunOnce section of the registry.

    This explains exactly how it's done.

    http://www.ehow.com/how_5175782_crea...ce-script.html
    Last edited by jinnantonnixx; 11th August 2011 at 11:32 PM.

  7. Thanks to jinnantonnixx from:

    networkingNut (12th August 2011)

  8. #6
    networkingNut's Avatar
    Join Date
    Oct 2008
    Location
    Midlands
    Posts
    144
    Thank Post
    15
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Quote Originally Posted by jinnantonnixx View Post
    Put a call to run the script in the RunOnce section of the registry.

    This explains exactly how it's done.

    How to Create a Runonce Script | eHow.com
    I will give that a go I think. If I am thinking correctly, it is just a case of placing the reg key on a shared directory, creating a batch script to call the key and when adding it to GPO putting /s in the 'switches' box?

    Or does the /s have to go directly after the filename?

    Code:
    \\server\SYSVOL\domain\scripts\Zeitgeist Client\newKey.reg /s

  9. #7

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,824
    Thank Post
    372
    Thanked 544 Times in 507 Posts
    Rep Power
    184
    Quote Originally Posted by networkingNut View Post
    I will give that a go I think. If I am thinking correctly, it is just a case of placing the reg key on a shared directory, creating a batch script to call the key and when adding it to GPO putting /s in the 'switches' box?

    Or does the /s have to go directly after the filename?

    Code:
    \\server\SYSVOL\domain\scripts\Zeitgeist Client\newKey.reg /s
    I'm not sure you're thinking runonce is what it is... It'll run once in terms on "not every startup", however if you've got the GPO applying everytime it'd still run everyone, just once per apply? If that makes sense. (Maybe I misunderstood how you worded that but we'll see)

    Steve

  10. #8

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,689
    Thank Post
    756
    Thanked 1,715 Times in 1,526 Posts
    Rep Power
    438

  11. #9

    jinnantonnixx's Avatar
    Join Date
    Mar 2011
    Location
    In the Calamatorium.
    Posts
    2,086
    Thank Post
    123
    Thanked 534 Times in 357 Posts
    Blog Entries
    2
    Rep Power
    336
    Are you using Windows 2008 server? If so, you can use a GPO to deploy the file. In fact, this is probably the easiest way.

    Create a GPO, under the Computer Configuration side, expand Preferences>Windows Settings>File

    Right click in the panel, and specify files to copy.

    Here, you can specify what happens if the file already exists. Choose 'Create'.

    This is quite a nice way of copying config files. There are other options, such as 'Delete' and 'replace' for when you need to change the config file at a later date.

  12. #10

    garethedmondson's Avatar
    Join Date
    Oct 2008
    Location
    Gowerton, Swansea
    Posts
    2,309
    Thank Post
    973
    Thanked 326 Times in 194 Posts
    Blog Entries
    11
    Rep Power
    170
    We use Impero for sending out quick files like this. It worked a treat when I had to make changes to Kodu on the fly.

    Gareth

  13. Thanks to garethedmondson from:

    russdev (17th August 2011)

  14. #11

    Join Date
    Sep 2009
    Posts
    224
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    13
    Personally speaking, i'd make a snapshot Msi containing the file(s) you want to deploy. I sent out our Crtl Alt Del background .bmp file using this method, and also a .Scr file. Works great, and its fuly automated for new computers to the network.

  15. #12
    networkingNut's Avatar
    Join Date
    Oct 2008
    Location
    Midlands
    Posts
    144
    Thank Post
    15
    Thanked 2 Times in 2 Posts
    Rep Power
    13
    Quote Originally Posted by Steve21 View Post
    I'm not sure you're thinking runonce is what it is... It'll run once in terms on "not every startup", however if you've got the GPO applying everytime it'd still run everyone, just once per apply? If that makes sense. (Maybe I misunderstood how you worded that but we'll see)

    Steve
    Are you suggesting it is best to remove the Script from the startup GPO and add it to the RunOnce folder in the registry?

    What I cant get my head around it how to copy the updated RunOnce Directory to multipe machines, without using the Startup script option in the GPO, ie to avoid making the RunOnce folder being copied multiple times.

    Hope that makes sense

    nN

  16. #13

    Join Date
    Jun 2011
    Posts
    12
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    When I do something like this, I put a flag on the client computer.....
    How?
    When you copy your config file, copy another small text file named after the version # (ie ver-1-1.txt).
    You will be able to use IF EXIST ver-1-1.txt in your batch file.
    If you push a never version (if not exist), first delete the old flag (DEL ver-*.txt) to avoid having multiple versions on the client.
    Easy and simple.

    Here is a good one for everybody.
    To push new files (or install software), I am using a small batch file to create a scheduled task on the WorkStations.
    Nobody has to be logged on the computers, they just have to be turned ON (advantage of using wakeup on LAN)
    You need a text file containing the name of the workstations (one name per line) where the software has to be installed (export the names from your AD).
    To push the scheduled task on the workstations, use the 'system' user (System is an administrator on all computers attached to the AD).
    The way that it works, you create a scheduled task to run in one hour. When the scheduled task is installed, you tell the WS to run it now.
    Here is an example:

    rem @echo off

    set program=D:\apps\xxx.exe
    set runtime=09:54

    rem +++++++++++++++++++++++++++++++
    rem + Do not modify anything under this line +
    rem +++++++++++++++++++++++++++++++

    set program1=%program%

    rem cd %0\..
    for /f %%i in (ws.txt) do (

    echo %program% was deployed at%TIME% on workstation %%i >> %program%.log

    copy %program% \\%%i\D$
    )

    rem ************************************************
    rem * now that the installation software is copied on the WS *
    rem * we create a schedule task for each WS and run it right away *
    rem * The switch /ST (start time) has to be set to a time greater *
    rem * than the actual time. Otherwise the task will never run. *
    rem ***********************************************

    for /f %%i in (ws.txt) do (
    SCHTASKS /Create /S %%i /z /F /RU SYSTEM /SC ONCE /ST %runtime% /TN %%i /TR "D:\%program1%
    SCHTASKS /run /S %%i /TN %%i
    )

    Bert



SHARE:
+ Post New Thread

Similar Threads

  1. Copying one file to multiple computers
    By WithoutMotive in forum How do you do....it?
    Replies: 16
    Last Post: 27th August 2012, 11:50 PM
  2. Replies: 6
    Last Post: 12th September 2011, 11:24 AM
  3. Copying files to multiple Kindles / other devices
    By mats in forum Netbooks, PDA and Phones
    Replies: 0
    Last Post: 27th January 2011, 05:44 PM
  4. Converting video files to be used on the web site
    By tosca925 in forum How do you do....it?
    Replies: 5
    Last Post: 28th April 2007, 08:31 AM
  5. Copy 2 files to every computer on the network
    By dezt in forum How do you do....it?
    Replies: 7
    Last Post: 5th July 2006, 12:43 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
  •