I have this here script that copys a database front-end (.mdb) to the local machine from the network. My 1st problem is that the copy method is stripping the file of the permissions it has, and not allowing it to inherit the permissions of the destination folder. I want to end up with the everyone group having modify permissions to the file. Can you change the permissions on a file via vbs?
My second problem is that I would like to display a status bar showing the file beinng copied. this script takes about 30 seconds to run, and I would like to give the user some idea that somthing is happening.
Thanks, Keith
My second problem is that I would like to display a status bar showing the file beinng copied. this script takes about 30 seconds to run, and I would like to give the user some idea that somthing is happening.
Thanks, Keith
Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'created 11.18.04 by keith walter for Syron Engineering '
'This script copies a new front end to the local machine '
'and executes it when called by the database '
' '
' version 1.0 - 1/8/05 - release '
' version 2.0 - 6/14/05 - updated for syron database '
' version 3.0 - 7/7/05 - changed copy method, added '
' 5sec sleep for file close '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Start
Dim strOldPath
Dim strNewPath
Dim FSO, f1
strOldPath ="C:\Program Files\SyronDatabase\syrondb.mdb"
strNewPath ="\\syron-ns-01\Public\Software\Database_Front_Ends\SyronDatabase\syrondb.mdb"
Set FSO = CreateObject("Scripting.FileSystemObject")
do while FSO.FileExists(Left(strNewPath, len(strNewPath)-3) & "ldb")=True
'As long as an ldb file exists, someone is in the database, so just do nothing until it goes away.
WScript.Sleep 1000
loop
Set f1 = fso.GetFile(strNewPath)
do while FSO.FileExists(Left(strOldPath, len(strOldPath)-3) & "ldb")=True
'As long as an ldb file exists, it's not closed yet, so just do nothing until it goes away.
WScript.Sleep 1000
loop
WScript.Sleep 15000 'wait for local database to finish closing all the way.
f1.Copy (strOldPath)
msgbox "Update complete. Open up the new database?", ,"Syron Database"
Set WshShell = WScript.CreateObject("WScript.Shell")
wshshell.run "MSACCESS.EXE " & Chr(34) & strOldPath & Chr(34)
'End