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!

Script works sometimes

Status
Not open for further replies.

NightZEN

Programmer
Apr 29, 2003
142
US
I have the following script that has worked on several Windows XP machines for 6 months, but fails at line 18 (FSO.CopyFile...) on Windows 2000. It may not be 2000 related, but I suspect it is. The 2000 user has the full admin rights that I do, so I am a bit lost. Can anyone help?!

Thanks, Keith




'Start
Dim strOldPath
Dim strNewPath
Dim FSO

strOldPath =left(wscript.scriptfullname,len(wscript.scriptfullname)-len(wscript.scriptname)) & "syrondb.mdb"
strNewPath ="\\syron-ns-01\Public\Software\Database_Front_Ends\SyronDatabase\syrondb.mdb"

Set FSO = CreateObject("Scripting.FileSystemObject")

do while FSO.FileExists(Left(strOldPath, len(strOldPath)-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 WshShell = WScript.CreateObject("WScript.Shell")

FSO.CopyFile strNewpath,strOldPath,True

WScript.Sleep 5000 'wait while file is copied

msgbox "update complete"

wshshell.run "MSACCESS.EXE " & Chr(34) & strOldPath & Chr(34)


'End
 
but fails at line 18
No error message ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
sorry here is the error:

Line: 18
Char: 1
Error: Permission denied
Code: 800A0046
Source: Microsoft VBScript runtime error
 
I'd check the value of strOldPath.
I'd try a manual copy with same user account.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Is it possible that it takes longer than 5 seconds to copy the file. This one can be a little tricky to track down because there could be some other network/computer activity happening that is causing the file to take longer to copy.

For example, there could be an anit-virus scan happening at the same time so a file that normally takes 1 second to copy now takes 20 seconds.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I believe the CopyFile method holds up script execution until the copy is completed.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top