Hello

I have a script that runs 24/24 7/7 on a server in an constant loop
gathering information into a DB. What i would like (and don't know how) is to
execute code to 'compact & repair' the database every time the server
shutsdown/reboots. So, the question is, is there any way to do this with
scripts, that is, to bypass the endless loop, executes final code and shuts
itself down without being forced?

Suggestions/links are welkome.

Greets
Davor

Re: Execute code before closing script by Tim

Tim
Mon Aug 22 09:10:35 CDT 2005

Davor,

Is your script automatically started when the server boots?

If so, (assuming I understand you correctly) it will be a lot easier to
to have your script compact and repair your DB as the first thing it
does *before* it goes into the infinite loop.

One way to compact your mdb is :

Dim JE,ActuallDB,TempDB,FSO,Prov

Set FSO = CreateObject("Scripting.FileSystemObject")

ActuallDB = "c:\mydb.mdb" 'this is your actual mdb

TempDB = "c:\mydb_temp.mdb"


Set JE=CreateObject("JRO.JetEngine")

Prov="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
JE.CompactDatabase Prov & ActuallDB & ";",Prov & TempDB & ";"

FSO.CopyFile TempDB,ActuallDB,true
FSO.DeleteFile TempDB

Regards,

Tim


Re: Execute code before closing script by Davor

Davor
Mon Aug 22 10:41:32 CDT 2005

Tim,

yes, you'r right, that is a possibility.

In the end, seems there is no way to exit the endles loop when shuting down
the system/script.

Greets
Davor

"Tim" wrote:

> Davor,
>
> Is your script automatically started when the server boots?
>
> If so, (assuming I understand you correctly) it will be a lot easier to
> to have your script compact and repair your DB as the first thing it
> does *before* it goes into the infinite loop.
>
> One way to compact your mdb is :
>
> Dim JE,ActuallDB,TempDB,FSO,Prov
>
> Set FSO = CreateObject("Scripting.FileSystemObject")
>
> ActuallDB = "c:\mydb.mdb" 'this is your actual mdb
>
> TempDB = "c:\mydb_temp.mdb"
>
>
> Set JE=CreateObject("JRO.JetEngine")
>
> Prov="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
> JE.CompactDatabase Prov & ActuallDB & ";",Prov & TempDB & ";"
>
> FSO.CopyFile TempDB,ActuallDB,true
> FSO.DeleteFile TempDB
>
> Regards,
>
> Tim
>
>