Hi
I'm a beginner with VB script and am trying to write a simple one to copy a file
The full script:
------
Dim strOldPath
Dim strNewPath
Dim FSO
strOldPath = "C:\Program Files\PhonApp\PhonApp.mdb"
strNewPath = "\\Se002\1Datas\Phon\Release\PhonApp.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.
Loop
Set wshshell = WScript.CreateObject("WScript.Shell")
FSO.CopyFile strNewPath, strOldPath, True
wshshell.Run strOldPath
-----
When I run this script I get the error message:
-----
Script \\se002\1Datas\Phon\Release/UpdateFrontEnd.vbs
LIne: 19
Char: 1
Error: The system cannot find the file specified
Code: 80070002
Source: (null)
-----
I'm imagining that the crash is on the line
FSO.CopyFile strNewPath, strOldPath, True
as it will expand to
FSO.CopyFile \\Se002\1Datas\Phon\Release\PhonApp.mdb, C:\Program Files\PhonApp.mdb, True
and the space in 'Program Files' confuses it. When I try it with a folder without a space its OK.
I've tried defining it as
strOldPath = """C:\Program Files\PhonApp\PhonApp.mdb"""
and
strOldPath = "'C:\Program Files\PhonApp\PhonApp.mdb'"
but it just comes up with different errors:
Any ideas?
I'm a beginner with VB script and am trying to write a simple one to copy a file
The full script:
------
Dim strOldPath
Dim strNewPath
Dim FSO
strOldPath = "C:\Program Files\PhonApp\PhonApp.mdb"
strNewPath = "\\Se002\1Datas\Phon\Release\PhonApp.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.
Loop
Set wshshell = WScript.CreateObject("WScript.Shell")
FSO.CopyFile strNewPath, strOldPath, True
wshshell.Run strOldPath
-----
When I run this script I get the error message:
-----
Script \\se002\1Datas\Phon\Release/UpdateFrontEnd.vbs
LIne: 19
Char: 1
Error: The system cannot find the file specified
Code: 80070002
Source: (null)
-----
I'm imagining that the crash is on the line
FSO.CopyFile strNewPath, strOldPath, True
as it will expand to
FSO.CopyFile \\Se002\1Datas\Phon\Release\PhonApp.mdb, C:\Program Files\PhonApp.mdb, True
and the space in 'Program Files' confuses it. When I try it with a folder without a space its OK.
I've tried defining it as
strOldPath = """C:\Program Files\PhonApp\PhonApp.mdb"""
and
strOldPath = "'C:\Program Files\PhonApp\PhonApp.mdb'"
but it just comes up with different errors:
Any ideas?