twillster Posted April 9, 2009 Share Posted April 9, 2009 There is a way to delete network connections without drive letters with DriveMapDel and the UNC path but is there any way to enumerate these connections so you know they are there to be deleted? I'm working on upgrading my login scripts from a combination of batch and kix scripts and want to know how to duplicate the net use * /delete /yes command. Deleting network connections that have drive letters assigned is easy via DriveGetDrive("NETWORK") but that doesn't get connections without drive letters. Anyone have any options other than running net use * /delete /yes from comspec? Thanks, Adam Link to comment Share on other sites More sharing options...
KaFu Posted April 9, 2009 Share Posted April 9, 2009 Hmmm, can not test it because I don't have shares here , but maybe WMI could help you. Compare the result with the result of DriveGetDrive("NETWORK") and delete those which are not assigned to a drive letter with "net use NAME /delete /yes". expandcollapse popup$wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Share", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output &= "AccessMask: " & $objItem.AccessMask & @CRLF $Output &= "AllowMaximum: " & $objItem.AllowMaximum & @CRLF $Output &= "Caption: " & $objItem.Caption & @CRLF $Output &= "Description: " & $objItem.Description & @CRLF $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output &= "MaximumAllowed: " & $objItem.MaximumAllowed & @CRLF $Output &= "Name: " & $objItem.Name & @CRLF $Output &= "Path: " & $objItem.Path & @CRLF $Output &= "Status: " & $objItem.Status & @CRLF $Output &= "Type: " & $objItem.Type & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Share" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Cyri Posted April 27, 2009 Share Posted April 27, 2009 Sounds like a suggestion for DriveMapDel("*") to me. I've recently run across a situation where that would have come in handy. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now