I have a folder that does exist on the network. When I run the following code before browsing to that directory (from Windows 7 Enterprise x64), it returns False. When I run the code after browsing to the directory, it returns True.
Const SHAREPOINT_FOLDER = "\\MyServer\sites\IT\MySite\Shared%20Documents\"
MsgBox sharePointExists()
Function sharePointExists()
Set fso = CreateObject("Scripting.FileSystemObject")
sharePointExists = fso.FolderExists(SHAREPOINT_FOLDER)
Set fso = Nothing
End Function
I have not tested this on any other OS. This is a SharePoint 2010 website directory. Again, the folder does exist and is readable and writable by me. If I browse to it manually in Windows Explorer, this script returns True until I restart my computer. Once I restart, the script returns False.
Any suggestions on making this work? It is a critical part of my program, and I need to have it work without manually browsing to the directory.
Note: I have replaced the FolderExists with FileExists and give it a valid filename. The same problem exists for FileExists.
If I substitute a Wscript.Shell object and execute a shell.Run, it opens the folder without trouble. This process takes several seconds (just like when I browse to it manually), but once I do this, I get True every time.
Be aware: If this function is run outside of my network, I want it to return False. I cannot assume it is True (otherwise I simply would not check for existence). Also, even on the network, this folder may not be accessible 100% of the time - another justification for checking the existence.