I have a script I have pieced together from a couple of threads (this is my first attempt at vbs). My intent is to check and see if the local copy of an Access DB file is the same as the server copy and if not replace the outdated local copy with the new server copy (this is a front end).
Then I want to run the current local copy.
Here is the code .vbs which resides in the same folder as the Server copy of the mdb which I have pieced together from a couple of sources:
It appears that the [blue]update s, t[/blue] is working fine. but it won't fire the [blue]sh.run[/blue] line even if the local copy and the server copy are the same which would not cause a [blue]f1.Copy target,True
[/blue] to be done...
Then I want to run the current local copy.
Here is the code .vbs which resides in the same folder as the Server copy of the mdb which I have pieced together from a couple of sources:
Code:
Function Update( source, target )
Dim f1,f2,d1,d2,c1,c2
If fs.FileExists( source ) then
set f1 = fs.GetFile( source )
d1 = f1.DateLastModified
c1 = Year(d1) * 10000 + Month(d1) * 100 + Day(d1)
If fs.FileExists( target ) then
set f2 = fs.GetFile( target )
d2 = f2.DateLastModified
c2 = Year(d2) * 10000 + Month(d2) * 100 + Day(d2)
Else
c2 = 0
End If
If c1 > c2 then
' overwrite local copy with the network version
f1.Copy target,True
End If
End If
End Function
Dim fs
set fs = WScript.CreateObject("Scripting.FileSystemObject")
s = "CommDInfo.mdb"
t = "C:\Documents and Settings\All Users\Documents\MSHPCommDInfo\CommDInfo.mdb"
Update s, t
Set Sh = CreateObject("WScript.Shell")
Sh.Run """C:\Documents and Settings\All Users\Documents\MSHPCommDInfo\CommDInfo.mdb"""
It appears that the [blue]update s, t[/blue] is working fine. but it won't fire the [blue]sh.run[/blue] line even if the local copy and the server copy are the same which would not cause a [blue]f1.Copy target,True
[/blue] to be done...