Code:
 Break on

SetConsole ("hide")
Global $scriptspath,$netpath,$workdir,$oralogon
$workdir = "c:\mtglaptop"
$scriptspath = "c:\mtglaptop\scripts"
$netpath = "\\server1\share\kixscripts"
$oralogon = "c:\oracle\ora81\bin\sqlplus user/password" + Chr(64) + "database"
Del $workdir +"files.dat"
Shell "%comspec% /e:1024 /c dir " + $netpath + " /b > " + $workdir + "\files.dat"
Shell "%comspec% /e:1024 /c dir " + $scriptspath + " /b >> " + $workdir + "\files.dat"
Open (1,"$workdir\files.dat",2)

Do
$file = ReadLine (1)
If @ERROR <> 0
$end=1
GoTo end
EndIf
$compare = CompareFileTimes ($netpath+ "\" + $file,$scriptspath+"\" + $file)
Select
Case $compare = 1
Copy $netpath +"\" + $file $scriptspath
?"copying " + $netpath "\" + $file
Case $compare = -2
Del $scriptspath + "\" $file
?"Deleting " + $scriptspath + "\" + $file
Case $compare = -3
Copy $netpath +"\" + $file $scriptspath
?"copying " + $netpath "\" + $file
Case $compare = 0
?$file + " Did not need to be updated"
EndSelect
:end
Until $end=1
Close (1)
Call $workdir +"\control.kix"


"Contol.KIX"

Break on
run "c:\$workdir\pbar.exe"
$File = "c:\mtglaptop\settings.ini"
If Exist($File)
$ScriptArray = Split(ReadProfileString($File,"",""),Chr(10))
For Each $script in $ScriptArray
If Val(ReadProfileString($File,$script,"run"))
? "Execute: " + $script
Else
? "DO NOT execute: " + $script
EndIf
Next
Else
? "File not found: " + $File
EndIf

INI File

[c:\mtglaptop\scripts\script1.kix]
run=1
[c:\mtglaptop\scripts\script2.kix]
run=0
[c:\mtglaptop\scripts\script3.kix]
run=1
[c:\mtglaptop\scripts\script4.kix]
run=1
[c:\mtglaptop\scripts\script5.kix]
run=1


PBAR.EXE
;This progress bar only simulates activity. This is to show the user that something is happening on the laptop and show tech support at what point the script may have failed. I use this for another script that I have written to build a personal oracle database or recover the database from a crashed laptop.

;****************************
;******Progress Bar**********
;****************************

SetConsole ("alwaysontop")
Break on

$time=@TIME
$database=0
$logdir="c:\db_fixes\kix"
If Exist ("$logdir\recover.log")
$log="$logdir\userfile.log"
$message="Copying Users personal files."
Else
$log="$logdir\ftp.log"
$message="Retrieving Maintenance Datafiles."
EndIf
$oranet="x:\oracle\oradata\mtglo"
$oralocal="c:\oracle\oradata\mtglo"
$file="\control01.dbf"
:progressbar
CLS
If Exist ("$logdir\fail.log")
GoTo failnet
EndIf
If Exist ("$log")
Select
Case $log="$logdir\fannie.log"
GoTo recovermsg
Case $log="$logdir\dispatch.log"
$log="$logdir\fannie.log"
$message="Copying Fannie Mae Files."
Case $log="$logdir\copy.log"
$log="$logdir\dispatch.log"
$message="Copying Freddie Mac Files."
Case $log="$logdir\notes.log"
$log="$logdir\copy.log"
$message=""
Case $log="$logdir\userfile.log"
$log="$logdir\notes.log"
$message = "Copy Lotus Notes Files."
Case $log="$logdir\personal.log"
GoTo message
Case $log="$logdir\import_end.log"
$log="$logdir\end_time_log"
$message="Updating Table Structure."
GoTo progressbar
Case $log="$logdir\personal.log"
GoTo message
Case $log="$logdir\userdetail.log"
$log="$logdir\personal.log"
$message="Personalizing Database."
Case $log="$logdir\lspwtables.log"
$log="$logdir\userdetail.log"
$message="Importing lspwtables Data."
GoTo progressbar
Case $log="$logdir\import6.log"
$log="$logdir\lspwtables.log"
$message="Importing Maintenance Data 6"
GoTo progressbar
Case $log="$logdir\import5.log"
$log="$logdir\import6.log"
$message="Importing Maintenance Data 5."
GoTo progressbar
Case $log="$logdir\import4.log"
$log="$logdir\import5.log"
$message="Importing Maintenance Data 4."
GoTo progressbar
Case $log="$logdir\import3.log"
$log="$logdir\import4.log"
$message="Importing Maintenance Data 3."
GoTo progressbar
Case $log="$logdir\import2.log"
$log="$logdir\import3.log"
$message="Importing Maintenance Data 2."
GoTo progressbar
Case $log="$logdir\import_start.log"
$log="$logdir\import2.log"
$message="Importing Maintenance Data 1."
GoTo progressbar
Case $log="$logdir\fileupdate.log"
$log="$logdir\import_start.log"
$message="Creating Oracle Database."
$database=1
GoTo progressbar
Case $log="$logdir\ftp.log"
$log="$logdir\fileupdate.log"
$message="Updating Orcle Configuration Files."


EndSelect
EndIf
:copyprog
If $log = "$logdir\copy.log"
Select
Case Exist ("$logdir\users01.log")
If Exist ("$logdir\copyfail.log")
Color n/n
Open (1,"$logdir\copyfail.log",2)
$copyfail=ReadLine (1)
Beep Beep Beep
Color r+/n
At (2,25) "ALERT ERRORS WHILE COPYING DATABASE"
While $copyfail>""
Color y+/n
?$copyfail
$copyfail=ReadLine (1)
Loop
Color n/n
Close (1)
Color g/n
;Gosub delete
At (22,28)"Press any key to Exit"
Get $end
Exit
EndIf
Case Exist ("$logdir\tools01.log")
$file = "\users01.dbf"
Case Exist ("$logdir\temp01.log")
$file = "\tools01.dbf"
Case Exist ("$logdir\system01.log")
$file = "\temp01.dbf"
Case Exist ("$logdir\redo03.log")
$file = "\system01.dbf"
Case Exist ("$logdir\redo02.log")
$file = "redo03.log"
Case Exist ("$logdir\redo01.log")
$file = "\redo02.log"
Case Exist ("$logdir\rbs01.log")
$file = "\redo01.log"
Case Exist ("$logdir\lsdata02.log")
$file = "\rbs01.dbf"
Case Exist ("$logdir\lsdata01.log")
$file = "\lsdata02.dbf"
Case Exist ("$logdir\control03.log")
$file = "\lsdata01.dbf"
Case Exist ("$logdir\control02.log")
$file = "\control03.ctl"
Case Exist ("$logdir\control01.log")
$file = "\control02.ctl"
EndSelect
Color g+/n
At (17,10) "Copying $oranet$file"
EndIf


Color y/n
Box(1,15,3,58,"double")
Color c+/n
If Exist ("$logdir\recover.log")
At (2,17) "Company Recovery Utility"
Else
At (2,17) "Company Setup Utility"
EndIf
Color g+/n
At(6,3)"Setup Start Time: " Color y+/n $time
Color w+/n
At(6,50)"Current Time: "
Color c+/n
If $database=1
At (17,12) "Running Oracle Scripts " Color r+/n "DO NOT " Color c+/n "Close out any Windows!"
At(15,20)"$message"
Else
At(15,20)"$message"

EndIf

Color b+/n
Box(10,10,12,65,"double")
$COL = 12
While $COL < 64
Color b+/n
Select
Case $col < 32
Gosub timer
Color r+/n
$sign = Chr(6) ; chr(176) for block bar "/"
Case $col < 48
Gosub timer
Color y+/n
$sign = Chr(7) ; chr(178) for block bar "\"
Case $col < 64
Gosub timer
Color g+/n
$sign = Chr(6) ; chr(177) for block bar "H"
EndSelect
At(11,$COL) $sign
$COL = $COL + 1
$Y = 100 * ($COL - 12) / 52
If ($COL & Rnd() ) = 0 ; simulate activiity
Sleep 1
EndIf

Loop


GoTo progressbar

:message
CLS

Close (9)
At(3,5)"Setup Start Time: " $time
At(3,46)"Setup Completion Time: " @TIME
Color m+/n
At (6,22)"******* SETUP IS COMPLETE *******"
Color b+/n
Gosub delete
At (22,28)"Press any key to Exit"
Get $end
GoTo scriptend

:recovermsg
Color y+/n
?"Recovery Started at $starttime Completed at @TIME"
Color r+/n
?"Press any key to exit" Get $done
Exit

:failnet
CLS
Open (1,"$logdir\fail.log",2)
$error=ReadLine (1)
Close (1)
CLS
At(3,5)"Setup Start Time: " $time
At(3,46)"Setup Stop Error Time: " @TIME
Color r+/n
At (8,10) $error
At (10,10)"******* FAILED TO CONNECT TO SOURCE COMPUTER *******"
Color y+/n
At (12,10)"1. Source computer is offline."
At (13,10)"2. Invalid computer name or IP Address."
Color b+/n
;Gosub delete
At (22,28)"Press any key to Exit"
Get $end
GoTo scriptend

:scriptend

Exit

:timer
Color y+/n
At(6,65)@TIME
Return
:delete

Del "$logdir\*.log"
Del "$logdir\newlo.sql"
Return






I have no problem with you ripping my code apart and showing me a more effienct way.


Edited by Fugazi (2004-09-30 11:40 PM)
_________________________
I haven't failed. I just found another way that did not work.