VM Shared Folders

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

VM Shared Folders

Post by jstevens »

Is it possible to determine if a shared folder (from a USB drive connected to a Guest Operating System) is accessible within the Host environment?

Example: The USB drive is connected to the Guest OS and is accessible via File Explorer from the Host OS (Windows 10). The challenge is when the USB drive is disconnected from the Guest OS. The Host OS shows the shared folder but it is greyed out. The test here is whether or not the USB drive is connected.

I appreciate your thoughts.
Regards,
John

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: VM Shared Folders

Post by jstevens »

I came up with a solution. If the USB drive is connected the "Type" shows up as a "File Folder" otherwise as a "File".

Code: Select all

Sub Test_Folder_Exists()

Set FSO = CreateObject("Scripting.FileSystemObject")
Dim Fldr_name As String

Fldr_name = "MyFolder"
  If FSO.FolderExists(Fldr_name) = True Then
    MsgBox "Folder Exists!"
  Else
    MsgBox "Connect Drive"
  End If
  
End Sub
Regards,
John

User avatar
HansV
Administrator
Posts: 78369
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VM Shared Folders

Post by HansV »

Thanks for sharing your solution.
Best wishes,
Hans