Using Xcopy in VBScript

Discussion in 'Visual Basic ( VB )' started by dariods, Dec 26, 2009.

  1. dariods

    dariods New Member

    Joined:
    Dec 26, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Unfortunately, xcopy doesn't take place. Could someone explain me what's wrong with the script and point me in the right direction to achieve points (1) - (5)? Thanks.This is my script
    Code:
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set wshShell = WScript.CreateObject("WScript.Shell")
    strUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")
    
    ' Discover Current Drive Path
    curDrv = objFSO.GetParentFolderName(WScript.ScriptFullName) 'Drive Path
    ' USB Drive  and folder Path
    upath = curdrv & "\ACG" 
    
    ' Source
    avg8 = "c:\Docume~1\alluse~1\applic~1\avg8\update\downloa  d\*.*"
    avg9 = "c:\Docume~1\alluse~1\applic~1\avg9\update\downloa  d\*.*"
    
    If struserName = DARIO Then 
      '(1) GOTO Update
    End If
    
    If Not objFSO.FolderExists (upath) Then
      objFSO.CreateFolder (upath)
    End If
    
    If objFSO.FolderExists (avg9) Then
      'WshShell.Run "xcopy c:\Docume~1\alluse~1\applic~1\avg9\update\download  \*.* usbdrive:\acg /D", , True
      '(2) WshShell.Run "xcopy avg9 upath /D", , True
      WshShell.Run "xcopy " & avg9 & " " & upath & " /D", , True
    End If
    
    If objFSO.FolderExists (avg8) Then
      'WshShell.Run "xcopy c:\Docume~1\alluse~1\applic~1\avg8\update\download  \*.* &    usbdrive:\acg & /D", , True
      '(3) WshShell.Run "xcopy avg8 upath /D", , True
      WshShell.Run "xcopy " & avg8 & " " & upath & " /D", , True
    End if
    
    MsgBox "Definition Files Copied to your USB Drive @ " & upath, vbInformation, "Copy   Success..."
    WScript.Quit
    
    ' Update 
    If Not objFSO.FolderExists("C:\Updates") Then
      objFSO.CreateFolder "C:\Updates"
    End If
    
    If objFSO.FolderExists (upath) then
      Wshshell.Run "xcopy " & upath  & " " & "C:\Updates /D", , True '(4)
      MsgBox "Update Files Copied to C:\Updates" , vbInformation, "Copy Destination"
    End IF
    
    ' Process
    Message = "Click OK to Start Updating product." & vbCr & vbCr
    Message = Message & "Click Cancel or (Esc) to Exit." &vbCr & vbCr
    Message = Message & "Keep Selecting OK until you get" & vbCr
    Message = Message & "the Message :-" & vbCr & vbCr
    Message = Message & "''No New Update Files Available''" & vbCR & vbCR
    X = MsgBox(Message, vbOKCancel, "AVG Update Module")
    
    Select Case X
      Case vbCancel 
        MsgBox (strUserName & " cancelled the process.") , vbCritical, "Operation Terminated."
        Wscript.Quit
    
      Case vbOK
        If objFSO.FileExists("C:\Program Files\AVG\AVG89\avgupd.exe") Then
          WshShell.Run "C:\Program Files\AVG\AVG9\avgupd.exe" /source=folder /path="C:\Updates"
        End If
    
        If objFSO.FileExists("C:\Program Files\AVG\AVG8\avgupd.exe") Then
          WshShell.Run "C:\Program Files\AVG\AVG8\avgupd.exe" /source=folder /path="C:\Updates"
          '(5) Loop to Process
        End If
    End Select
     
    Last edited by a moderator: Dec 26, 2009
  2. nimesh

    nimesh New Member

    Joined:
    Apr 13, 2009
    Messages:
    769
    Likes Received:
    20
    Trophy Points:
    0
    Occupation:
    Oracle Apps Admin
    Location:
    Mumbai
    Home Page:
    http://techiethakkar.blogspot.com
    Can you give the error that you get for the script?

    First try with just a simple statement of 2-3 lines, instead of going for the whole code.
    See if it works.
     
  3. dariods

    dariods New Member

    Joined:
    Dec 26, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I get the msgbox of Copy Success but nothing gets copied
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice