////////////////////////////////////////////////////////////// // // Automates VREPAIR for mounted volumes on NWv3/NWv4 Servers // ////////////////////////////////////////////////////////////// // Change to the System Console screen before processing. CHANGE_SCREEN "System Console" // Clear the System Console screen. CLS // The following displays the currently mounted // volumes on the console screen. VOLUMES // Capture the current System Console screen image as // text (default mode). SAVE_SCREEN SYS:SYSTEM\VOLUMES.SCR // Open the System Console screen text image for input. OPEN_READ SYS:SYSTEM\VOLUMES.SCR // This WHILE/LOOP scans for the string "Mounted Volumes" // in each line of the captured System Console screen. // Mounted Volumes is displayed on the line preceding // the Volume names shown by the VOLUMES console command. // (Note: The first pass fails since %1 is not defined.) WHILE NOT SCAN_STRING "Mounted Volumes" "%1" // The "Mounted Volumes" string was not found so read the next // line from the input file (System Console screen text image). READ %1 // Abort the Task if a read error occurs. IF ERRORLEVEL ECHO Read error occurred! ABORT ENDIF // If the read returns a null string, exit since the // System Console screen should be padded with spaces. // (Note: No spaces are allowed between the strings and // the operators in comparisons.) IF "%1"=="" ECHO Unable to locate volume information! ABORT ENDIF // Repeat the process until "Mounted Volumes" // or a null string is found. LOOP // Load the VREPAIR NLM. LOAD VREPAIR // Abort this Task if VREPAIR cannot be loaded. IF ERRORLEVEL ECHO Unable to load VREPAIR! ABORT ENDIF // The following WHILE/LOOP tests if the read string is null // The first pass it will not be since it matched above. // (Note: No spaces are allowed between the strings and the // operators in comparisons.) WHILE "%1">"" // Read the next line from the captured System Console screen READ %1 // Abort the Task if a read error occurs. IF ERRORLEVEL ECHO Read error occurred - Must be the End of File??? BREAK ENDIF // If the string "DOS" is not found on the line, probably // is not a volume since DOS Name Space support is typical. IF NOT SCAN_STRING "DOS" "%1" THEN CONTINUE // In this example, we do not want to process the SYS: volume. // (Note: If repair of the SYS: volume is desired, VRepair // will have to be loaded from the DOS partition, // LOAD C:\NETWARE\VREPAIR. The captured screen // image will also have to be saved to the DOS // partition (DEFINE %0 C:\VOLUMES.SCR) and the // VRepair error log file will need to be saved // to the DOS partition (see below). IF SCAN_STRING "SYS" "%1" CONTINUE ENDIF // Dismount the volume in order to perform VRepair. DISMOUNT %1 // Make sure the VRepair Status Screen is active. CHANGE_SCREEN "VRepair Status Screen" // Repair the first (only) dismounted volume. KEYIN "1" ENTER // Use F1 key to change the default options KEYIN F1 // Pause a second to let it activate the appropriate screen WAIT 1 // Change to the VRepair Error Screen and set the // options not to prompt for keyins. CHANGE_SCREEN "VRepair Error Screen" // Check if Pause after errors is enabled IF SCAN_SCREEN "1. Do not pause after errors" THEN KEYIN "1" ENTER // Check if Log errors to a file is enabled IF SCAN_SCREEN "2. Log errors to a file" // Select 2 to log errors to a file KEYIN "2" ENTER // Specify the name of the VRepair error log file KEYIN "SYS:SYSTEM\VREPAIR.ERR" ENTER // Check if file exist prompt appears and select Append IF SCAN_SCREEN "1. Append to" THEN KEYIN "1" ENTER ENDIF // Continue the VRepair process. KEYIN "0" ENTER // Pause a second to let it reset the options WAIT 1 // Switch the default screen back to the VRepair // Status Screen so we can check for completion. CHANGE_SCREEN "VRepair Status Screen" // This Task uses the %9 user defined variable to // track how long VRepair works. // Set %9 to the proper numeric value and compare length. DEFINE %9 000 // Scan the screen for the prompt // which indicates completion of the VRepair. WHILE NOT SCAN_SCREEN "Press any key" // Pause 1 second before continuing with the loop WAIT 1 // Increment the counter after each 1 second pause. DEFINE %9 %9+=1 // If more than 5 minutes passes (300 seconds), // better abort since it should not take that long // to repair the volume. // (Note: This may need to be adjusted depending // upon volume size and file count.) IF %9>300 ECHO VRepair has run for 5 minutes. ECHO Maybe there is a problem?!?! ABORT ENDIF // Continue processing the next volume shown. LOOP // Clear the prompt KEYIN ENTER // Remount the volume just repaired. MOUNT %1 // Repeat the process until no more Volumes exist. // (Note: We assume no more volumes exist if we // do not find the string "DOS" on the line, // i.e., typical NetWare volumes will have // DOS Name Space support which appears // beside the volume name.) LOOP // Finished with VRepair UNLOAD VREPAIR // Delete the temporary file where we wrote the // captured System Console screen image. DEL SYS:SYSTEM\VOLUMES.SCR