I hope this is posted in the correct area. The below code I wrote as my first Power Basic Application and may not fully understand how I accomplished what I did but it does what I need. The comments I would like to solicite are related to the way it appears when executed. The progarm works as designed for the backup. When run not only does the application not show up in the task bar nor give any indication that it is running, (I think that's great!) I am not sure how this was accomplished even though I did it
. The application shows as running only in the task manager in windows. Everyday at 6pm it executes and backs up the storage drive it was designed to backup then quietly awaits the next day at 6pm to do it again. I like it and hope others may also find a use for it. It could be improved by allowing the program to figure out for itself the directory structure of the drive to be backed up then duplicate it instead of the current hard coded directory structure for backup which will cause an Error 76 bad path if the directory structure to be backed up does not match. Anyway could someone explain why it only shows up in the task manager for windows, I guess this is like a bug which is found to provide a benefit and then becomes an added feature! Here is the code:
Thanks for any comments, once again if I offended anyone placing this in an inappropriate area please let me know where this kind of stuff needs to go. I see a lot of talent on this forum and would like to solicite some input from the experts. Thanks again. Wayne

Code:
'============================================================================== ' Created by: W.R. Suite ' Last Modified on: 11/15/2007 ' Purpose: Automatic Remote Drive Backup to Local Drive ' Designed For: DFW Airport Board ETM '============================================================================== ' Designer Notes: Create Copy of Remote Drive/Directory and Files on Local ' Once started application will monitor time past since ' midnight and initiate automatic backup of remote drive at ' 6 pm each evening 24/7 as long as program is running in ' the background and terminated by task manager. ' 'Operational Goals: The backup will check and create the backkup directory ' structure if it does not exist on the Backup destination. ' Then all files in all sub directories off the main ' directory will be copied to the same on the destination ' drive in the same folders mirroring the target source. '============================================================================== #COMPILE EXE #DIM ALL '==================== ' Constants '==================== %MB_ICONINFORMATION = &H00000040& '==================== 'Variables '==================================== GLOBAL D AS STRING GLOBAL BD AS STRING GLOBAL TD AS STRING GLOBAL BFD() AS STRING GLOBAL MonthDirectory() AS STRING '==================================== ' SubRoutines Area '============================================================================== SUB InitializeLocations '============================================================================== 'Assigns initial values to string arrays 'Refreshes string arrays once they are adjusted or changed '============================================================================== DIM BFD(7) AS GLOBAL STRING :' Base Directory String Array Number of Base Directories + 1 DIM MonthDirectory(12) AS GLOBAL STRING :' Sub Directory String Array '========================================================================== 'Assign Backup Directory Strings '========================================================================== TD = "C:" :' Target Backup Location BD = "E:" :' Source Drive Location D = "\FY08_UTILITIES" '========================== 'Base Directories '========================== BFD(0) = D & "\ELECTRIC-FY08\" BFD(1) = D & "\GAS-FY08\" BFD(2) = D & "\WATER-FY08\" BFD(3) = D & "\CNG-FY08\" BFD(4) = D & "\PROPANE-FY08\" BFD(5) = D & "\DFWBIO-FY08\" BFD(6) = D & "\REFUELING-FY08\" '========================== 'Sub Directories under Base '========================== MonthDirectory(0) = "OCTOBER-FY08\" MonthDirectory(1) = "NOVEMBER-FY08\" MonthDirectory(2) = "DECEMBER-FY08\" MonthDirectory(3) = "JANUARY-FY08\" MonthDirectory(4) = "FEBRUARY-FY08\" MonthDirectory(5) = "MARCH-FY08\" MonthDirectory(6) = "APRIL-FY08\" MonthDirectory(7) = "MAY-FY08\" MonthDirectory(8) = "JUNE-FY08\" MonthDirectory(9) = "JULY-FY08\" MonthDirectory(10) = "AUGUST-FY08\" MonthDirectory(11) = "SEPTEMBER-FY08\" '============================================================================== END SUB '============================================================================== SUB CreateBackupStructure '============================================================================== 'Creates the Exact Backup Directory Structure on the Destination Backup Drive '============================================================================== DIM DCount AS INTEGER :' Directory String Array Identifier DIM SDCount AS INTEGER :' Sub Directory String Array Identifier DIM AD AS STRING :' Active Directory DIM ASD AS STRING :' Active Sub Directory DIM NDir AS STRING :' Directory Drive & Name to Create '========================================================================== 'Create Main Diretory on Destination Drive '========================================== NDir = TD & D MKDIR(NDir) IF ERR>0 THEN MSGBOX("Cannot Create the Directory: " & Ndir) '========================================== 'Create the Sub Directories of the Main '========================================== NDir = TD & D CHDIR(NDir) '=============================== 'True Number of Base Directories '=============================== FOR DCount = 0 TO 6 '=============================== AD = TD & BFD(DCount) MKDIR(AD) IF ERR>0 THEN MSGBOX("Cannot Create the Directory: " & AD) NEXT '============================================================== 'Create the Sub Directories of the Sub Directories of the Main '============================================================== 'True Number of Base Directories '=============================== FOR DCount = 0 TO 6 '=============================== AD = TD & BFD(DCount) CHDIR(AD) FOR SDCount = 0 TO 11 ASD = MonthDirectory(SDCount) MKDIR(ASD) IF ERR>0 THEN MSGBOX("Cannot Create the Directory: " & ASD) NEXT NEXT '============================================================================== END SUB '============================================================================== SUB CheckBackupStructure :' OK 10/13/2007 '============================================================================== 'Checks the target Backup Drive to see if the Backup Directory Structure Exists 'If the structure does not exist then Creates Exact Mirrored Backup Directory 'Structure on the targeted Backup Destination Drive '============================================================================== DIM Checkdrive AS STRING '=========================================================== 'Does the main directory Exist? 'ERR = 76 if Main Directory does not exist on target '=========================================================== CheckDrive = TD & D CHDIR(CheckDrive) IF ERR>0 THEN CreateBackupStructure '============================================================================== END SUB '============================================================================== SUB Backitup '============================================================================== 'This routine performs the actual backup operations at the specified time 'TM - Minute Time extracted from System Time Clock 'TH - Hour Time extracted from System Time Clock '============================================================================== DIM TM AS INTEGER :' Time in Minutes DIM HR AS INTEGER :' Time in Hours DIM SMSG AS STRING :' Successful Completion Message Holder DIM DCount AS INTEGER :' Directory String Array Identifier DIM SDCount AS INTEGER :' Sub Directory String Array Identifier DIM AD AS STRING :' Active Directory DIM ASD AS STRING :' Active Sub Directory '============================================ 'Variables utilized in the Backup Operations '============================================ DIM FNameList(1000) AS STRING DIM AFCount AS INTEGER :' Active File Count for Backup DIM CCount AS INTEGER :' File Copy Counter DIM LDir AS STRING DIM LSDir AS STRING DIM CurrentFileName AS STRING DIM FSource AS STRING DIM FTarget AS STRING '========================================================================== 'Wait for Hour to match then Minute Time to 'Pass plus 5 Seconds then perform the backup '============================================ DO UNTIL HR = 18 AND TM > 00 HR = VAL(LEFT$(TIME$,2)) TM = VAL(MID$(TIME$,4,2)) SLEEP 5000 LOOP '============================================================================ 'Create a list of all filenames of files in all directories below the main 'directory of the source drive and folder. File List does NOT include Drive! '============================================================================ AFCount = 0 CCount = 0 '=============================== 'True Number of Base Directories '=============================== FOR DCount = 0 TO 6 '=============================== LDir = BD & BFD(DCount) CHDIR LDir FOR SDCount = 0 TO 11 LSDir = BD & BFD(DCount) & MonthDirectory(SDCount) CHDIR LSDir CurrentFileName = DIR$("*.pdf") WHILE LEN(CurrentFileName) AND AFCount < 1000 FNameList(AFCount) = BFD(DCount) & MonthDirectory(SDCount) & CurrentFileName INCR AFCount INCR CCount CurrentFileName = DIR$ WEND NEXT NEXT '========================================================================== 'Utilizing the just created filepath & filenames copy all the files from 'the source drive/directories to the Backup Destination Drive/Directories. 'The only change being the drive designator for the copied files. BD is the 'Base Drive or Source Drive while TD is the Target Drive or Destination. '========================================================================== FOR CCount = 0 TO (AFCount-1) FSource = BD & FNameList(CCount) FTarget = TD & FNameList(CCount) FILECOPY FSource, FTarget IF ERR>0 THEN MSGBOX("Error #: " & STR$(ERR)& " Occured!") NEXT '=============================================================================================== 'Send message indicating time of backup completion 'then wait for user acknowledgement before exiting '=============================================================================================== SMSG = "Backup was Completed at: " & TIME$ & $CRLF & " Total Files Backed Up: " & STR$(AFCount) MSGBOX SMSG, %MB_ICONINFORMATION, "Backup Routine" '=============================================================================================== '=================================================== END SUB '============================================================================== ' Main Code Routine '============================================================================== FUNCTION PBMAIN() Restart: InitializeLocations CheckBackupStructure Backitup GOTO Restart END FUNCTION '==============================================================================
Comment