GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

VBS to Close Open Network Shared file

Home Forums Scripting Windows Script Host VBS to Close Open Network Shared file

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    vane0326
    Member
    #165467

    Hi,

    I have this code below that will close all files in a particular SHARED Network folder. I would like to be modified to just close a particular file only.

    Code:
    strComputer = “file-server”
    strFolder = “G:HR”

    On Error Resume Next

    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set objShell = WScript.CreateObject(“WScript.Shell”)

    Set objConnection = GetObject(“WinNT://” & strComputer & “/LanmanServer”)
    Set colResources = objConnection.Resources

    For Each objResource in colResources
    strParent = objFSO.GetParentFolderName(objResource.Path)

    If LCase(strParent) = LCase(strFolder) Then
    objShell.Run “openfiles /disconnect /s ” & strComputer & ” /id ” &_
    objResource.Name, 0, False
    End If
    Next

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.