+ Post New Thread
Results 1 to 5 of 5
How do you do....it? Thread, VB Script ti check for folder and then copy contents to PC in Technical; I need a vb script that will check to see if a folder is in the c:\program files, if it ...
  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

    VB Script ti check for folder and then copy contents to PC

    I need a vb script that will check to see if a folder is in the c:\program files, if it is then do nothing if not then copy the folder and its contents to the c:\program files of the pc from an area on the network.

    I have a script that does this on one folder and one file but i want it to copy the contents of an whole folder?

    Must be a VB as we ban .bat files.

  2. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,803
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: VB Script ti check for folder and then copy contents to PC

    What about .cmd?

  3. #3
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    22

    Re: VB Script ti check for folder and then copy contents to PC

    would prefer VB :-)

  4. #4

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,344
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414

    Re: VB Script ti check for folder and then copy contents to PC

    Code:
    ' NewFolderEC.vbs
    ' Free example VBScript to create a folder with error-correcting Code.
    ' Author Guy Thomas http://computerperformance.co.uk/
    ' Version 2.6 - May 2005
    ' ---------------------------------------------------------------'
    
    Option Explicit
    Dim objFSO, objFolder, objShell, strDirectory
    strDirectory = "c:\program files\Directory to create"
    
    ' Create the File System Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    ' Note If..Exists. Then, Else ... End If construction
    If objFSO.FolderExists(strDirectory) Then
       Set objFolder = objFSO.GetFolder(strDirectory)
    'folder allready exists
    Else
       Set objFolder = objFSO.CreateFolder(strDirectory)
    'Create Folder
    End If
    
    If err.number = vbEmpty then
       Set objShell = CreateObject("WScript.Shell")
    Else WScript.echo "VBScript Error: " & err.number
    End If
    
    WScript.Quit
    
    ' End of Sample VBScript to create a folder with error-correcting Code
    
    'Now add files to folder suing suitable code
    Ben

  5. #5

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,344
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414

    Re: VB Script ti check for folder and then copy contents to PC

    Code:
    SET G = oFS.GetFolder(<specified folder on server>)
    SET f = G.Files
        FOR EACH f1 in f
            oFS.CopyFile f1, <new location>,TRUE
        NEXT
    Should copy everything from the source folder to the destination.

    Ben

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 29th January 2013, 10:16 AM
  2. Replies: 17
    Last Post: 19th March 2010, 11:51 PM
  3. Replies: 4
    Last Post: 25th December 2006, 09:15 PM
  4. Replies: 3
    Last Post: 1st March 2006, 12:08 PM
  5. Replies: 2
    Last Post: 1st October 2005, 02:55 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
  •