I have been searching and searching to try and find a way to check and see if a file is open or not but I have had no luck so far.
The over all bigger picture is that I wrote a vb script to run as an update, but before running the update I want to check if the program is open or not and if it is to prompt the user that the program is open and that they need to close it before the update will run.
Any help would be much appreciated!
Thanks,
Slen
Here is what I have so far. Just trying to figure out how I can add to this to check if the file is open...
Expand|Select|Wrap|Line Numbers
- Dim x
- x=MsgBox("Do you wish to install the Program?",1,"File Install")
- If x = vbOK then
- Const FULL_PATH = "C:\DatabaseTestFolder"
- Set fso = CreateObject("Scripting.FileSystemObject")
- BuildPath FULL_PATH
- CreateFile
- End if
- Sub CreateFile()
- dim filesys
- dim strFile
- dim strDest
- strFile = "C:\Documents and Settings\Desktop\Test.accde"
- strDest = "C:\DatabaseTestFolder\Test.accde"
- set filesys=CreateObject("Scripting.FileSystemObject")
- If filesys.FileExists(strFile) Then
- filesys.CopyFile strFile, strDest
- MsgBox("The file has been saved to your C:\Drive as " & strDest)
- End If
- If err.Number <> 0 then
- msgbox(err.Description & " " & err.Number)
- Else
- msgbox("Testing")
- End if
- End Sub
- Sub BuildPath(ByVal Path)
- If Not fso.FolderExists(Path) Then
- BuildPath fso.GetParentFolderName(Path)
- fso.CreateFolder Path
- End If
- End Sub