Public Class AppManager
Shared Sub Main()
' Set form style defaults
' Test for command line parameters.
If Environment.GetCommandLineArgs.Length > 1 Then
' If in batch mode just instantiate the FileCopy class as no form is needed.
' Also don't declare this class "withevents" as the events only report status
' data (like the number of files copied so far).
Dim BatchCopy As New FileCopy
' Setup the copy parameters for the BatchCopy instance from command line arguments
Dim Argument As String
Dim Index As Integer = 0
For Each Argument In Environment.GetCommandLineArgs
Select Case Index
' The first argument is the app file/path so do nothing
BatchCopy.FromPath = Environment.GetCommandLineArgs(1).ToString
BatchCopy.ToPath = Environment.GetCommandLineArgs(2).ToString
If Environment.GetCommandLineArgs(3).ToString.ToUpper = "TRUE" Then
BatchCopy.MirrorCopy = True
BatchCopy.MirrorCopy = False
If Environment.GetCommandLineArgs(4).ToString.ToUpper = "TRUE" Then
BatchCopy.QuietLog = True
BatchCopy.QuietLog = False
' Ignore any remaining arguments as something is wrong. The BatchCopy class
' will log any errors in the log file.
Index += 1
' Start the multithreaded copy
BatchCopy.InitialMessage = "*** MODE IS BATCH ***"
If BatchCopy.MirrorCopy Then
BatchCopy.InitialMessage = "*** MODE IS BATCH - MIRROR COPY IS SET ***"
If BatchCopy.QuietLog Then
BatchCopy.InitialMessage += vbCrLf & "Logging is quiet - not verbose."
BatchCopy.InitialMessage += vbCrLf & "Logging is not quiet - its verbose."
BatchCopy.BatchCopy = True
' Forms mode so open the Backup form. The Backup from will instantiate the FileCopy class
' when the "Go" button is pressed.
Dim BackupForm As Backup
BackupForm = New Backup()
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)