Forum Discussion

fmendes's avatar
fmendes
Contributor
13 years ago

Robocopy Example

Could you share a sample on how to run robocopy from a TestComplete script?



Thanks in advance.

1 Reply

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Luis,


    You can use the Windows Script Host objects. For instance, the following code runs Notepad and loads a file in it:

    Sub Test1

      ' Specify the application and its command line

      ' Don't forget quotes for the arguments that contain spaces

      RunProgram "Notepad.exe ""C:\My File.txt"" "

    End Sub



    Sub RunProgram(AFileName)

      Set WSH = CreateObject("WScript.Shell")

      WSH.Run AFileName, 1, true

    End Sub


    You can run robocopy in a similar way. 


    For more information on running programs with WScript, see MSDN, for example: http://technet.microsoft.com/en-us/library/ee156605.aspx.


    A possible alternative is to add robocopy to your project's TestedApps list and then run it as a tested application.