home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / A_Folder_&206340512007.psc / frmDisk.frm < prev   
Text File  |  2007-05-01  |  25KB  |  733 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmBackup 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Path Full/Incremental Backup"
  6.    ClientHeight    =   8400
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   6960
  10.    Icon            =   "frmDisk.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    ScaleHeight     =   8400
  14.    ScaleWidth      =   6960
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.Frame fraDiff 
  17.       Caption         =   "Differential"
  18.       Height          =   825
  19.       Left            =   390
  20.       TabIndex        =   15
  21.       Top             =   5040
  22.       Width           =   4155
  23.       Begin VB.CheckBox chkByDateTime 
  24.          Caption         =   "by Date && Time"
  25.          Height          =   285
  26.          Left            =   2220
  27.          TabIndex        =   17
  28.          Top             =   330
  29.          Width           =   1545
  30.       End
  31.       Begin VB.CheckBox chkByDateOnly 
  32.          Caption         =   "by Date only"
  33.          Height          =   285
  34.          Left            =   390
  35.          TabIndex        =   16
  36.          Top             =   330
  37.          Width           =   1425
  38.       End
  39.    End
  40.    Begin VB.CommandButton cmdHelp 
  41.       Caption         =   "Hel&p"
  42.       Height          =   375
  43.       Left            =   5370
  44.       TabIndex        =   14
  45.       Top             =   4800
  46.       Width           =   855
  47.    End
  48.    Begin VB.TextBox txtHLQ 
  49.       Alignment       =   2  'Center
  50.       BeginProperty Font 
  51.          Name            =   "MS Sans Serif"
  52.          Size            =   12
  53.          Charset         =   0
  54.          Weight          =   700
  55.          Underline       =   0   'False
  56.          Italic          =   0   'False
  57.          Strikethrough   =   0   'False
  58.       EndProperty
  59.       Height          =   420
  60.       Left            =   3840
  61.       TabIndex        =   8
  62.       Text            =   "Backup"
  63.       Top             =   6030
  64.       Width           =   2775
  65.    End
  66.    Begin MSComctlLib.ProgressBar pbarDone 
  67.       Height          =   375
  68.       Left            =   345
  69.       TabIndex        =   12
  70.       Top             =   6630
  71.       Width           =   6255
  72.       _ExtentX        =   11033
  73.       _ExtentY        =   661
  74.       _Version        =   393216
  75.       Appearance      =   1
  76.       Scrolling       =   1
  77.    End
  78.    Begin VB.CheckBox chkSimulate 
  79.       Caption         =   "&Simulate backup and log only.  No file copying."
  80.       Height          =   255
  81.       Left            =   420
  82.       TabIndex        =   6
  83.       Top             =   4620
  84.       Width           =   4215
  85.    End
  86.    Begin VB.CheckBox chkForceFull 
  87.       Caption         =   "&Force full backup of all ""From"" files if checked, else incremental backup will be performed"
  88.       Height          =   405
  89.       Left            =   420
  90.       TabIndex        =   5
  91.       Top             =   4140
  92.       Width           =   4215
  93.    End
  94.    Begin VB.Frame fraTo 
  95.       Caption         =   """To"" Drive"
  96.       Height          =   795
  97.       Left            =   150
  98.       TabIndex        =   3
  99.       Top             =   3270
  100.       Width           =   6615
  101.       Begin VB.DriveListBox Drive2 
  102.          Height          =   315
  103.          Left            =   240
  104.          TabIndex        =   4
  105.          Top             =   240
  106.          Width           =   6225
  107.       End
  108.    End
  109.    Begin MSComctlLib.StatusBar sbr 
  110.       Align           =   2  'Align Bottom
  111.       Height          =   315
  112.       Left            =   0
  113.       TabIndex        =   11
  114.       Top             =   8085
  115.       Width           =   6960
  116.       _ExtentX        =   12277
  117.       _ExtentY        =   556
  118.       _Version        =   393216
  119.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  120.          NumPanels       =   3
  121.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  122.             AutoSize        =   1
  123.             Object.Width           =   7091
  124.          EndProperty
  125.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  126.             Style           =   6
  127.             Alignment       =   1
  128.             TextSave        =   "5/1/2007"
  129.          EndProperty
  130.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  131.             Style           =   5
  132.             Alignment       =   1
  133.             TextSave        =   "11:49 AM"
  134.          EndProperty
  135.       EndProperty
  136.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  137.          Name            =   "MS Sans Serif"
  138.          Size            =   8.25
  139.          Charset         =   0
  140.          Weight          =   700
  141.          Underline       =   0   'False
  142.          Italic          =   0   'False
  143.          Strikethrough   =   0   'False
  144.       EndProperty
  145.    End
  146.    Begin VB.CommandButton cmdExit 
  147.       Cancel          =   -1  'True
  148.       Caption         =   "E&xit"
  149.       Height          =   375
  150.       Left            =   5370
  151.       TabIndex        =   10
  152.       Top             =   5300
  153.       Width           =   855
  154.    End
  155.    Begin VB.CommandButton cmdScan 
  156.       Caption         =   "&Backup"
  157.       Height          =   375
  158.       Left            =   5370
  159.       TabIndex        =   9
  160.       Top             =   4300
  161.       Width           =   855
  162.    End
  163.    Begin VB.Frame fraFrom 
  164.       Caption         =   """From"" Path"
  165.       Height          =   2895
  166.       Left            =   150
  167.       TabIndex        =   0
  168.       Top             =   150
  169.       Width           =   6615
  170.       Begin VB.DirListBox Dir1 
  171.          Height          =   1890
  172.          Left            =   240
  173.          TabIndex        =   2
  174.          Top             =   712
  175.          Width           =   6225
  176.       End
  177.       Begin VB.DriveListBox Drive1 
  178.          Height          =   315
  179.          Left            =   240
  180.          TabIndex        =   1
  181.          Top             =   240
  182.          Width           =   6225
  183.       End
  184.    End
  185.    Begin VB.Label lblBytes 
  186.       Alignment       =   2  'Center
  187.       BorderStyle     =   1  'Fixed Single
  188.       BeginProperty Font 
  189.          Name            =   "MS Sans Serif"
  190.          Size            =   12
  191.          Charset         =   0
  192.          Weight          =   700
  193.          Underline       =   0   'False
  194.          Italic          =   0   'False
  195.          Strikethrough   =   0   'False
  196.       EndProperty
  197.       Height          =   405
  198.       Left            =   330
  199.       TabIndex        =   19
  200.       Top             =   7080
  201.       Width           =   6255
  202.    End
  203.    Begin VB.Label lblSpeed 
  204.       Alignment       =   2  'Center
  205.       BorderStyle     =   1  'Fixed Single
  206.       BeginProperty Font 
  207.          Name            =   "MS Sans Serif"
  208.          Size            =   12
  209.          Charset         =   0
  210.          Weight          =   700
  211.          Underline       =   0   'False
  212.          Italic          =   0   'False
  213.          Strikethrough   =   0   'False
  214.       EndProperty
  215.       Height          =   405
  216.       Left            =   330
  217.       TabIndex        =   18
  218.       Top             =   7560
  219.       Width           =   6255
  220.    End
  221.    Begin VB.Label Label1 
  222.       Alignment       =   1  'Right Justify
  223.       AutoSize        =   -1  'True
  224.       Caption         =   "&High level qualifier (Blank to have a same name, mirror copy of source directory tree.)"
  225.       Height          =   390
  226.       Left            =   420
  227.       TabIndex        =   7
  228.       Top             =   6030
  229.       Width           =   3270
  230.       WordWrap        =   -1  'True
  231.    End
  232.    Begin VB.Label lblCurrDir 
  233.       Height          =   390
  234.       Left            =   345
  235.       TabIndex        =   13
  236.       Top             =   6570
  237.       Width           =   6255
  238.       WordWrap        =   -1  'True
  239.    End
  240. End
  241. Attribute VB_Name = "frmBackup"
  242. Attribute VB_GlobalNameSpace = False
  243. Attribute VB_Creatable = False
  244. Attribute VB_PredeclaredId = True
  245. Attribute VB_Exposed = False
  246. Option Explicit
  247.  
  248.   'This code was based on a source submission on
  249.   'Planet-Source-Code in 2003 named "diskscan"
  250.   'written by Manoz Shrivastava
  251.   'My thanks to the author for posting a very good
  252.   'base for my use in creating this backup program.
  253.  
  254.   Public NotUsed As String  ' Just to keep the comments here and out of the first code module. (error in VB)
  255.   
  256.   Public gbChkRunning As Boolean
  257. Function DoDateFmt(sInDate As String) As String
  258.  
  259. ' Dim sInput As String
  260. ' Dim sPiece As String
  261.  Dim sBuild As String
  262. ' Dim i As Long
  263.  
  264.  'Date coming in in the format 6/18/2003 4:57:04 PM
  265.  'Reformat to YYYYMMDDHHMMSS and the HH will be 24 hour
  266.  
  267.  sBuild = Year(sInDate) & Right("0" & Month(sInDate), 2) & Right("0" & Day(sInDate), 2)
  268.  sBuild = sBuild & Right("0" & Hour(sInDate), 2) & Right("0" & Minute(sInDate), 2) & Right("0" & Second(sInDate), 2)
  269.  
  270.  DoDateFmt = sBuild
  271.  
  272. End Function
  273.  
  274. Sub MakeNewPath(sNewPath As String)
  275.  
  276.  'Well, it seems that the directory path I need is not there and FSO, stupidly, won't make it for me.
  277.  'Why?  Will never know!  It really, really should.  MkDir won't do it either.  Has to be done one level at a time.
  278.  'OK, Here we go...  slowly...
  279.  
  280.   Dim iCurrBS As Long  ' Where the current backslash I am working with is.
  281.   Dim sCurrPath As String  ' Built up from sNewPath in the error catcher routine.
  282.   
  283.   iCurrBS = 3
  284.   Do While iCurrBS > 0
  285.     iCurrBS = InStr(iCurrBS + 1, sNewPath, "\")
  286.     sCurrPath = Mid$(sNewPath, 1, iCurrBS)
  287.     On Error Resume Next
  288.     If iCurrBS > 0 Then MkDir sCurrPath
  289.     On Error GoTo 0
  290.   Loop
  291.   
  292. End Sub
  293.  
  294. Function BuildTargetPath(sSourcePath As String) As String
  295.  
  296.   Dim i As Long
  297.   Dim sBuild As String
  298.   Dim sRebuild As String
  299.   
  300.   i = InStrRev(sSourcePath, "\")
  301.   sBuild = Mid$(sSourcePath, 2, i - 1)
  302.   If gsBackupHiLvlName = "" Then
  303.     sBuild = sTargetDrive & Left(sBuild, 2) & Mid$(sBuild, 3, i - 3)
  304.     i = 4
  305.   Else
  306.     sBuild = sTargetDrive & Left(sBuild, 2) & gsBackupHiLvlName & "\" & Mid$(sBuild, 3, i - 3)
  307.     i = 5 + Len(gsBackupHiLvlName)
  308.   End If
  309.   
  310.   i = InStr(i, sBuild, "\")
  311.   sRebuild = Left(sBuild, i - 1)
  312.   
  313.   If bParmDateDifferential Then
  314.     sRebuild = sRebuild & "_" & Left(DoDateFmt(gsSaveStartTime), 8)
  315.     ElseIf bParmDateTimeDifferential Then sRebuild = sRebuild & "_" & Left(DoDateFmt(gsSaveStartTime), 12)
  316.   End If
  317.   
  318.   BuildTargetPath = sRebuild & Mid$(sBuild, i)
  319.   
  320. End Function
  321. Sub DoBackup()
  322.  
  323.   Dim i As Long
  324.   Dim sNewPath As String
  325.   Dim sTemp As String
  326.   Dim cStartSeconds As Currency
  327.   Dim cBytesPerSecond As Currency
  328.   Dim cSecsNow As Currency
  329.   Dim cRunTimeSeconds As Currency
  330.   
  331.   pbarDone.Max = CLng(dKiloBytesTotal)
  332.   pbarDone.Visible = True
  333.   lblCurrDir.Visible = False
  334.   lblBytes.Visible = True
  335.   lblSpeed.Visible = True
  336.   lFilesCopied = 0
  337.   cStartSeconds = Timer()
  338.   cBytesPerSecond = 0
  339.   
  340.   sbr.Panels(1).Text = "Copying up to " & glFiles & " files."
  341.  'If bParmSimulateExist Then Me.Caption = "Backup: Copying up to " & glFiles & " files."
  342.   If Me.WindowState = vbMinimized Then
  343.     Me.Caption = "Backup: Copying up to " & glFiles & " files."
  344.   Else
  345.     Me.Caption = gsFullSizeCaption
  346.   End If
  347.   
  348.   For i = 1 To glFiles
  349.     If bExitReq Then
  350.       Close
  351.       Unload Me
  352.       End
  353.     End If
  354.     'Debug.Print sFileModDateTime(i) & " " & sLastRunDateTime
  355.     If sFileModDateTime(i) > sLastRunDateTime Then
  356.       If gbDetailed_Logging Then DebugLog "Candidate " & Right("     " & i, 5) & " " & sFilesList(i)
  357.      'If the force checkbox is not checked and the input parm did not come in copy the file.
  358.       If Not (bParmSimulate) Then
  359.         
  360.         sNewPath = BuildTargetPath(sFilesList(i))  ' Add in all the optional stuff, if any, to get the output path.
  361.         
  362.         sTemp = Dir$(sNewPath, vbDirectory)  ' Is the output path there?
  363.         If sTemp = "" Then MakeNewPath sNewPath  ' If not, go make it up NOW!
  364.         
  365.         If Not bParmForcedFull Then DebugLog "Copying " & sFilesList(i) & " to " & sNewPath
  366.         
  367.         On Error GoTo CantDoCopyfile
  368.         FSO.CopyFile sFilesList(i), sNewPath, True
  369.         On Error GoTo 0
  370.         dKiloBytesDone = dKiloBytesDone + dFileSizes(i)
  371.         lFilesCopied = lFilesCopied + 1
  372.         If Timer() < cStartSeconds Then  ' Have we just gone past midnight?
  373.           cSecsNow = 86400 - cStartSeconds + Timer()  ' Yes, take yesterday's seconds plus todays.
  374.         Else
  375.           cSecsNow = Timer() - cStartSeconds  ' No, just get elapsed seconds today so far.
  376.         End If
  377.         lblSpeed = "Copying " & Format(dKiloBytesDone / cSecsNow, "standard") & " Kilobytes/second."
  378.       End If
  379.     Else
  380.       Debug.Print "Simulated Copy " & sFilesList(i)
  381.     End If
  382.     pbarDone.Value = CLng(dKiloBytesDone)
  383.     sbr.Panels(1).Text = "Of " & glFiles & " source files, " & lFilesCopied & " copied."
  384.     lblBytes = Int(dKiloBytesDone) & " KB of " & Int(dKiloBytesTotal) & " KB copied."
  385.     If i Mod 10 = 0 Then
  386.       If Me.WindowState = vbMinimized Then
  387.         Me.Caption = "Backup: Of " & glFiles & " candidates, " & lFilesCopied & " copied."
  388.       Else
  389.         Me.Caption = gsFullSizeCaption
  390.       End If
  391.       DoEvents
  392.     End If
  393.   Next
  394.   
  395.   DebugLog "Backup complete."
  396.   
  397. Exit Sub
  398.  
  399. CantDoCopyfile:
  400.   
  401.   DebugLog "Error '" & Err.Description & "' copying " & sFilesList(i), True
  402.   Close
  403.   Unload Me
  404.   End
  405.   
  406. End Sub
  407.  
  408. Sub DriveProcess()
  409.  
  410.   Dim i As Integer
  411.   Dim sDateSettingParm As String  ' Concat of input path, output drive and HLQ for hanging backup date on.  All 3 are needed for uniqueness.
  412.   
  413.   DebugLog "Starting."
  414.   bRunning = True
  415.   bExitReq = False  ' Not exiting (Exit button has not been pressed)
  416.   pbarDone.Visible = False
  417.  
  418.   If chkByDateOnly.Value = vbChecked Then bParmDateDifferential = True
  419.   If chkByDateTime.Value = vbChecked Then bParmDateTimeDifferential = True
  420.   
  421.   If bParmInputPath Then  ' If this is an automatic run
  422.     sSourceFolder = gsStartingSourceDir  ' Use directory name from command$
  423.   Else
  424.     sSourceFolder = Dir1.List(Dir1.ListIndex)  ' Use directory name from the directory listbox
  425.   End If
  426.  'Accept 2, 3, 4, 5 and 6 only
  427.   i = GetDriveType(Left(sSourceFolder, 3))
  428.   Select Case i
  429.     Case 2, 3, 4, 5, 6
  430.      'Nop
  431.     Case Else
  432.       DebugLog "Invalid drive selection for input drive."
  433.       Close
  434.       Unload Me
  435.       End
  436.   End Select
  437.   
  438. ' Select Case GetDriveType(drive)
  439. '   Case 2
  440. '     getType = "Removable"
  441. '   Case 3
  442. '     getType = "Drive Fixed"
  443. '   Case 4
  444. '     getType = "Remote"
  445. '   Case 5
  446. '     getType = "Cd-Rom"
  447. '   Case 6
  448. '     getType = "Ram disk"
  449. '   Case Else
  450. '     getType = "Unrecognized"
  451. '  'End Case Else
  452. ' End Select
  453.   
  454.   If bParmOutputPath Then  ' If this is an automatic run
  455.     sTargetDrive = gsOutputDriveLetter
  456.   Else
  457.     sTargetDrive = Left(Drive2.Drive, 1)
  458.   End If
  459.  'Accept 2, 3, 4 and 6 only
  460.   i = GetDriveType(Left(sTargetDrive & ":\", 3))
  461.   Select Case i
  462.     Case 2, 3, 4, 6
  463.      'Nop
  464.     Case Else
  465.       DebugLog "Invalid drive selection for output drive."
  466.       Close
  467.       Unload Me
  468.       End
  469.   End Select
  470.   
  471.   gsBackupHiLvlName = Trim$(txtHLQ)  ' Either user typed or input parms might have put something here.
  472.   If sTargetDrive = Left(sSourceFolder, 1) And Trim$(gsBackupHiLvlName) = "" Then
  473.     DebugLog "Cannot backup to same drive without entering a high level qualifier.  Select another drive or enter a high level qualifier and try again.", True
  474.     Exit Sub
  475.   End If
  476.   
  477.   sDateSettingParm = UCase(sSourceFolder & " " & sTargetDrive & " " & gsBackupHiLvlName)
  478.   If chkForceFull.Value = vbChecked Or bParmForcedFull Then  ' Either the box is checked or
  479.     sLastRunDateTime = "01/01/1900 00:00:01 AM"
  480.     DebugLog "Forced full backup copy will be made."
  481.   Else
  482.     sLastRunDateTime = GetSetting(App.EXEName, "LastRunDate", sDateSettingParm, "01/01/1900 00:00:01 AM")
  483.     DebugLog "Updates only run.  Copying all files after " & sLastRunDateTime
  484.   End If
  485.   gsSaveStartTime = Now()
  486.   
  487.   sLastRunDateTime = DoDateFmt(sLastRunDateTime)
  488.     
  489.   fraFrom.Enabled = False
  490.   fraTo.Enabled = False
  491.   fraDiff.Enabled = False
  492.   cmdScan.Enabled = False
  493.   chkForceFull.Enabled = False
  494.   chkSimulate.Enabled = False
  495.   txtHLQ.Enabled = False
  496.   
  497.   glFiles = 0  ' Reset to use first array entry next time.
  498.   DebugLog "Copying from " & sSourceFolder
  499.   DebugLog "Copying to   " & sTargetDrive & ":\" & gsBackupHiLvlName & "\" & Mid$(sSourceFolder, 4)
  500.   
  501.   Set strFolder = FSO.GetFolder(sSourceFolder)
  502.   
  503.   MapDirs (strFolder)
  504.   
  505.   DebugLog "Found " & glFiles & " files in selected path."
  506.   DoEvents
  507.     
  508.   DoBackup
  509.   
  510.  'fraFrom.Enabled = True
  511.  'fraTo.Enabled = True
  512.  'cmdScan.Enabled = True
  513.  'chkForceFull.Enabled = True
  514.  'chkSimulate.Enabled = True
  515.  'txtHLQ.Enabled = True
  516.   
  517.   DebugLog lFilesCopied & " of " & glFiles & " files copied to target."
  518.   sbr.Panels(1).Text = "Copied " & lFilesCopied & " of " & glFiles & " files."
  519.  'If bParmSimulateExist Then Me.Caption = "Backup: Copied " & lFilesCopied & " of " & glFiles & " files."
  520.   If Me.WindowState = vbMinimized Then
  521.     Me.Caption = "Backup: Copied " & lFilesCopied & " of " & glFiles & " files."
  522.   Else
  523.     Me.Caption = gsFullSizeCaption
  524.   End If
  525.   If chkSimulate.Value = vbChecked Then bParmSimulate = True
  526.   
  527.   bRunning = False
  528.   
  529.  'Not that the run is finished, update the cutoff time for the next run.
  530.   If chkSimulate.Value = vbUnchecked And Not (bParmDateTimeDifferential) And Not (bParmDateDifferential) Then SaveSetting App.EXEName, "LastRunDate", sDateSettingParm, gsSaveStartTime
  531.   
  532. End Sub
  533.  
  534. Private Sub chkByDateOnly_Click()
  535.  
  536.     
  537.   If gbChkRunning Then Exit Sub
  538.   gbChkRunning = True
  539.   
  540.  'chkByDateOnly.Value = vbChecked
  541.   chkByDateTime.Value = vbUnchecked
  542.   
  543.   gbChkRunning = False
  544.   
  545. End Sub
  546.  
  547. Private Sub chkByDateTime_Click()
  548.  
  549.   If gbChkRunning Then Exit Sub
  550.   gbChkRunning = True
  551.   
  552.  'chkByDateTime.Value = vbChecked
  553.   chkByDateOnly.Value = vbUnchecked
  554.   
  555.   gbChkRunning = False
  556.  
  557. End Sub
  558.  
  559.  
  560. Private Sub chkForceFull_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  561.   sbr.Panels(1).Text = "Force complete backup"
  562. End Sub
  563.  
  564.  
  565. Private Sub cmdExit_Click()
  566.   
  567.   If Not bRunning Then
  568.     Close
  569.     Unload Me
  570.     End
  571.     Exit Sub
  572.   End If
  573.   
  574.   bExitReq = True
  575.  
  576. End Sub
  577.  
  578. Private Sub cmdExit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  579.   sbr.Panels(1).Text = "Exit"
  580. End Sub
  581.  
  582. Private Sub cmdHelp_Click()
  583.   frmAbout.Show
  584. End Sub
  585.  
  586. Private Sub cmdScan_Click()
  587.   DriveProcess
  588. End Sub
  589.  
  590. Private Sub cmdScan_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  591.   sbr.Panels(1).Text = "Backup files from 'From' path to 'To' drive."
  592. End Sub
  593.  
  594. Private Sub Dir1_Change()
  595.  'ChDir Dir1.Path
  596. End Sub
  597.  
  598. Private Sub Drive1_Change()
  599.   
  600.   On Error Resume Next
  601.   ChDrive Drive1.Drive
  602.   Dir1.Path = Drive1.Drive
  603.   On Error GoTo 0
  604.   
  605. End Sub
  606.  
  607. Private Sub Form_Load()
  608.       
  609.   Dim sMyParms() As String
  610.   Dim sMyCommand As String
  611.   Dim sTemp As String
  612.   Dim i As Long
  613.   
  614.   gsFullSizeCaption = "Path Full/Incremental Backup vers:" & App.Major & "." & App.Minor & "." & App.Revision
  615.   Me.Caption = gsFullSizeCaption
  616.   
  617.  'Test parms to copy to D disk with HLQ, forced DateTimeDiff backup:    -i C:\My.VB\File Backup -q Backups -o d -t
  618.  'Test parms to copy to D disk with HLQ, forced DateDiff backup:        -i C:\My.VB\File Backup -q Backups -o d -d
  619.  'Test parms to copy to D disk with HLQ, forced full backup, simulated: -i C:\My.VB\File Backup -q Backups -o d -f -s
  620.  'Test parms to copy to C disk with HLQ, forced full backup:            -i C:\My.VB\File Backup -q Backups -o c -f
  621.  'Test parms to copy to D disk NO   HLQ, incremental (error):           -i C:\My.VB\File Backup -o c
  622.  
  623.  'Set up defaults to start with.
  624.   strPath = App.Path
  625.   Set strFolder = FSO.GetFolder(strPath)  ' Just a default will almost certainly be overridden later.
  626.  
  627.   bRunning = False  ' Not running yet.  Exit works differently depending on running or not.
  628.   gbChkRunning = False
  629.   
  630.   pbarDone.Value = pbarDone.Max
  631.   dKiloBytesTotal = 0
  632.   dKiloBytesDone = 0
  633.   
  634.  'Input parms description
  635.  '  -i is input path for top level to copy.  All lower levels will be copied.
  636.  '  -q is the high level qualifier to use to put the files under.  If missing, "Backup" is used.
  637.  '  -o is the drive to place the backup tree structure on.
  638.  '  -f (switch -- no parms required) sets a forced full backup of the entire tree.
  639.  '  -s (switch -- no parms required) only simulate the copy and log it, do not copy any files.
  640.  '  -d (switch -- no parms required) Do date differential (-f will cause a dated full)
  641.  '  -t (switch -- no parms required) Do Date & Time differential (-f will cause a dated full)
  642.  
  643.  'Assume no parms are there.
  644.   bParmInputPath = False
  645.   bParmHighLvlQual = False
  646.   bParmDateDifferential = False
  647.   bParmForcedFull = False
  648.   bParmSimulate = False
  649.   bParmDateDifferential = False
  650.   bParmDateTimeDifferential = False
  651.   
  652.   sMyCommand = Command$
  653.   sMyCommand = Replace(sMyCommand, sQuote, "")
  654.   If Trim$(sMyCommand) <> "" Then DebugLog "Input parms to program: " & sMyCommand
  655.   sMyParms = Split(sMyCommand, "-")
  656.   bErrorInParms = False  ' assume no errors
  657.  
  658.   If UBound(sMyParms) > 0 Then
  659.     Me.Show
  660.     Me.WindowState = vbMinimized
  661.     
  662.     bParmSimulateExist = True
  663.     
  664.     For i = 0 To UBound(sMyParms)
  665.       DebugLog i & " " & sMyParms(i)
  666.       Select Case UCase(Left(sMyParms(i), 1))
  667.   '    -i is input path for top level to copy.  All lower levels will be copied.
  668.         Case "I"
  669.           bParmInputPath = True
  670.           gsStartingSourceDir = Trim$(Mid$(sMyParms(i), 3))
  671.           Drive1.Drive = gsStartingSourceDir
  672.           Dir1.Path = gsStartingSourceDir
  673.           
  674.   '    -q is the high level qualifier to use to put the files under.  If missing, "Backup" is used.
  675.         Case "Q"
  676.           bParmHighLvlQual = True
  677.           txtHLQ = Trim$(Mid$(sMyParms(i), 3))  ' This is where it is picked up later and put into the global
  678.        
  679.   '    -o is the output drive to place the backup tree structure on. Can be the same drive as I if Q is not blank.
  680.         Case "O"
  681.           bParmOutputPath = True
  682.           gsOutputDriveLetter = UCase(Mid$(sMyParms(i), 3, 1))
  683.           Drive2.Drive = gsOutputDriveLetter
  684.           
  685.   '    -f (switch -- no parms required) sets a forced full backup of the entire tree.
  686.         Case "F"
  687.           bParmForcedFull = True
  688.           chkForceFull.Value = vbChecked
  689.           
  690.   '    -s (switch -- no parms required) only simulate the copy and log it, do not copy any files.
  691.         Case "S"
  692.           bParmSimulate = True
  693.           chkSimulate.Value = vbChecked
  694.           
  695.   '    -d (switch -- no parms required) force a separate 'date differential' path on each run based on date.
  696.         Case "D"
  697.           bParmDateDifferential = True
  698.           chkByDateOnly.Value = vbChecked
  699.           
  700.   '    -t (switch -- no parms required) force a separate 'date_time differential' path on each run based on date.
  701.         Case "T"
  702.           bParmDateTimeDifferential = True
  703.           chkByDateTime.Value = vbChecked
  704.           
  705.       End Select
  706.     Next
  707.     DoEvents
  708.     DebugLog "Input parms found.  Run mode: Automatic in the background."
  709.     DebugLog "Input Parm -- Source Directory: " & gsStartingSourceDir
  710.     DebugLog "Input Parm -- Output drive letter: " & gsOutputDriveLetter
  711.     DebugLog "Input Parm -- High Level Output Qualifier: " & txtHLQ
  712.     If bParmForcedFull Then
  713.       DebugLog "Input Parm -- This will be a forced full backup."
  714.     Else
  715.       DebugLog "Input Parm -- This will be a partial back of changed files since last run."
  716.     End If
  717.     If bParmSimulate Then
  718.       DebugLog "Input Parm -- This will be a simulation run, no data copying.  Run date not udpated."
  719.     Else
  720.       DebugLog "Input Parm -- This will be a live run with data copying and run date will be updated."
  721.     End If
  722.     sTemp = Dir$(gsStartingSourceDir, vbDirectory)
  723.     If sTemp = "" Then
  724.       DebugLog "ERn  
  725.  
  726.     Enate.Enabled = Tru    DoEventsll be a partial ba "Input parms found.  Rackup:         Enate.Enabled = Tru      If Nr$(orce(orcial ba "Input parms found.  Rarate 'id Sub
  727.  
  728. Private Sub cmdHelp_Click()
  729.   frmAbout.Show
  730. End Sub
  731.  
  732. Private Sub cmdScan_Click()
  733.   DrN'ycE-ate