Answered Backup Data To Current Drive VBS

  • Wednesday, July 04, 2012 4:21 PM
     
     

    I am new and just trying to have a vb script that backs up the data from one location to another drive. Currently with the specified paths it backs from C:\ to D:\ drive. I would like to be able to backup to current drive that the script is on or any other drive if needed. I am not a programmer, any suggestions would be appreciated.

    Snippet of Code I am using.

    Dim fldr
    Dim fldrSource
    Dim fldrDest
    Dim shell
    Dim gso

    set gso = CreateObject("Scripting.FileSystemObject")
    if (gso.DriveExists("D:")) Then
      if NOT (gso.FolderExists("D:\Current_ServiceData_Backup")) Then
        gso.CreateFolder("D:\Current_ServiceData_Backup")
    '  else
        if NOT (gso.FolderExists("D:\Current_ServiceData_Backup\Test")) Then
          gso.CreateFolder("D:\Current_ServiceData_Backup\Test")
        end if
      end if
    else
      msgbox("drive error, D: does not exist")
    end if

    'Dim fso, fldr
    Set fso = CreateObject("Scripting.FilesystemObject")
    Set fldr = fso.GetFolder("D:\Current_ServiceData_Backup")
    'delete subfolders
    For Each subf In fldr.SubFolders

    subf.Delete True

    Next

    'delete subfiles
    For Each fsofile In fldr.Files

    fsofile.Delete True

    Next
     
    gso.CreateFolder("D:\Current_ServiceData_Backup\Testfiles")

    '**********************************************************************************************************

    TransferByDateAndExt "C:\test\Resources\Event_log\","D:\Current_ServiceData_Backup\Event_log",10,"txt"

    Please advice

All Replies

  • Wednesday, July 04, 2012 4:28 PM
     
     

    Kevin,

    This is not a forum for VB Script; this is for VB Net.

    I know a forum exists for scripting but I don't know the URL to it.


    Please call me Frank :)

  • Wednesday, July 04, 2012 6:35 PM
     
     

    There is no VBScript forum here, as VBScript is esentially a depreciated technology in favor of Windows PowerShell. There is a scripting forum, but that focuses on JavaScript, and VBA is a bit too different from VBScript to group them together.

    I suggest trying one of the 3rd party sites in the sticky thread above about getting help with VB6 questions. Sites like VBForums.com still offer help with VB6 and VBScript code.


    Matt Kleinwaks - MSMVP MSDN Forums Moderator - www.zerosandtheone.com

  • Thursday, July 05, 2012 3:24 AM
     
     

    Hi Kevin,

    Thanks for your post. For VB Script issue, I would refer you to The Official Scripting Guys Forum! (http://social.technet.microsoft.com/Forums/en-US/ITCG/threads) for support. 

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us

  • Thursday, July 05, 2012 4:04 AM
     
     Answered

    I am not a programmer, any suggestions would be appreciated.

    This is a scripting  forum mostly for techjnicians who use scripitn n their work.  We do not usually do custom scripting.  Ther are script in teh repository that may be useful.

    If you are just trying to get someone to fix a production script then I suggest you call in a consultant.  If you are trying to learn scripting then tell us what is failing or what error you are getting with your script.

    Please understand that posting scripts that you do not understand and asking for someone to fix them is not what this forum is for.

    You have asked for a change to a script. Review the scripting literature here and  try and fix your script. Post back with specific questions.


    ¯\_(ツ)_/¯

  • Thursday, July 05, 2012 12:38 PM
     
     Answered

    Hi,

    Take a look at robocopy tool, there's no need to reinvent the wheel ;-)

    http://en.wikipedia.org/wiki/Robocopy


    Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu