Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET

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

  • 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.

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: