Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change permissions via vbscript to a file, show status

Status
Not open for further replies.

NightZEN

Programmer
Apr 29, 2003
142
US
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

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
 
Replace this:
f1.Copy (strOldPath)
By this:
Dim SA, dest
Set SA=CreateObject("Shell.Application")
Set dest=SA.NameSpace(Left(strOldPath,InStrRev(strOldPath,"\")-1))
dest.CopyHere strNewPath,16

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top