+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, Script needed to check for file, rename and then copy a file in Coding and Web Development; I am useless at scripts but need someone to help me out. I need a script to run in a ...
  1. #1
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    22

    Script needed to check for file, rename and then copy a file

    I am useless at scripts but need someone to help me out. I need a script to run in a GPO on computer start up.

    I need it to check for a file in systems 32, ie, c:\windows\system32\file.dll.

    If it exists i need the script to rename the file to oldfile.dll.

    Then the script needs to copy a new file.dll to the same location from a folder on the server.



    Could anyone please help me.

  2. #2

    Join Date
    Feb 2006
    Location
    South Gloucestershire
    Posts
    23
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Script needed to check for file, rename and then copy a

    Try This

    Code:
    ::____________Start Script______________________
    :: check if oldfile.dll exists, if so script has already run
    if exist "%windir%\system32\oldfile.dll" goto :EOF
    :: if oldfile.dll does not exist and file.dll does exist then we need to act
    if exist "%windir%\system32\file.dll" rename "%windir%\system32\file.dll" oldfile.dll
    :: now copy the new file from the server
    copy "\\server\share\file.dll" "%windir%\system32\file.dll"
    @echo Job Completed
    ::____________End Script______________________
    beware of the word wrap, the orphaned oldfile.dll on line 6 belongs on the end of line 5

  3. #3

    Join Date
    Feb 2006
    Location
    South Gloucestershire
    Posts
    23
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Script needed to check for file, rename and then copy a

    Me again, there are lots of word wrap issues in that code, copy and paste seems to make it OK but just in case I have attached the file to this post. You will need to change the extention to cmd - but you knew that anyway (I just can't upload .cmd files)
    Attached Files Attached Files

  4. #4

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,846
    Thank Post
    110
    Thanked 592 Times in 513 Posts
    Blog Entries
    1
    Rep Power
    226

    Re: Script needed to check for file, rename and then copy a file

    Windows System File Protection will eat you alive.

  5. #5

    Join Date
    Feb 2006
    Location
    South Gloucestershire
    Posts
    23
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Script needed to check for file, rename and then copy a

    Only partly true, if it is a system dll then I agree, if it is a dll put there by a 3rd party app then probably not - I have not seen many of them go to the bother of protecting their dlls.

    However our school is mostly w2k and the age of most of the software reflects that environment so I may well be wrong about this specific case.

    If the file is under the protection of sfp then I agree that the job becomes a little more problematic than the would be addressed by the simple script that I offered but it does what was asked for (I think) and if more is actually needed we can look at that after Tosca has tried it in his environment.



SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 17
    Last Post: 20th March 2010, 12:51 AM
  2. Rename a PC from a batch file - Any ideas?
    By MrLudwig in forum Windows
    Replies: 13
    Last Post: 8th December 2007, 03:40 AM
  3. Replies: 4
    Last Post: 25th December 2006, 10:15 PM
  4. VB Script ti check for folder and then copy contents to PC
    By tosca925 in forum How do you do....it?
    Replies: 4
    Last Post: 2nd October 2006, 09:15 PM
  5. Replies: 3
    Last Post: 1st March 2006, 01:08 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
  •