Forum Discussion

dyoakum's avatar
dyoakum
New Contributor
11 years ago

Shell executing Xcopy in TestComplete

Is there an equivalent to "Xcopy" in TestComplete, like aq.xcopy?

2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi,


     


    TestComplete provides the aqFileSystem.CopyFolder and aqFile.Copy methods you can work with.


     


    Also, you can execute the Xcopy command in TestComplete in the following way:




    //JScript


      var operation = "\"C:\\Folder\\2\\*\" \"C:\\Folder\\1\" /i /s";


      Xcopy(operation);


    ...


     


    function Xcopy(operation)


    {


     var WScriptObj = Sys.OleObject("WScript.Shell");


     WScriptObj.Exec("Xcopy " + operation); 


    }



  • dyoakum's avatar
    dyoakum
    New Contributor
    Thank you so much!

    Actually, I should have added "using vbscipt", but your response gave me a V8 wakeup call and I came up with the following...


    Sub



      XCopySomeFiles()



      Dim svOperation



      'XCOPYCommandLineStringToExecute = "XCOPY.EXE " & svSOURCEFOLDER & arrInternalMapTesterFileNames(i) & " " & svTARGETFOLDER & " /c /d /f /o /q /v /y"



      svOperation = "C:\TestLogs\XcopyTest.txt _ C:\TestImages\ /c /d /f /o /q /v /y"



      Call XCopyEXE(svOperation)



    End



    Sub



    Function XCopyEXE(svXCopyOperation)



      Dim oWScript, oExec



      Set oWScript = CreateObject("WScript.Shell")



      XCopyEXE = False



      Set oExec = oWScript.Exec("C:\Windows\System32\Xcopy " & svXCopyOperation)



      If Not aqFileSystem.Exists("C:\TestImages\XcopyTest.txt") Then



        Log.Error("Error - XCopying operation did not succeed for the operation: '" & svXCopyOperation & "'.")



      End If



      Set oWScript = Nothing



      Set oExec = Nothing



    End Function