Tsiyoshi Posted July 6, 2009 Posted July 6, 2009 Hello, I am trying to delete some network paths that are no longer valid. these paths may vary by name but all start with the same server name: \\charlie-1 If I use "drivemapdel" I can only give a specific path after server name but what I need is some sort of a way to delete anything after \\charlie-1\* Anyone has an idea? Thanks in advance.
bogQ Posted July 6, 2009 Posted July 6, 2009 Hello,I am trying to delete some network paths that are no longer valid. these paths may vary by name but all start with the same server name: \\charlie-1If I use "drivemapdel" I can only give a specific path after server name but what I need is some sort of a way to delete anything after \\charlie-1\*Anyone has an idea? Thanks in advance.if folder is behinde maped drive you can useDirRemove("Y:\Test1", 1) to delite folder in maped driveor DirRemove("\\Pascal\D\hh", 1) to delite whats in shared folder"drivemapdel" is only used to Disconnects a network drive not to delite it TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Lars Posted July 6, 2009 Posted July 6, 2009 #include <Process.au3> _RunDOS ( "net use \\pascal /delete" ) The simple and easyway
Tsiyoshi Posted July 6, 2009 Author Posted July 6, 2009 Thank you for the reply but ( "net use \\pascal /delete" ) will not work because it needs another parameter afterwards. for instance: ( "net use \\pascal\hd /del" )
99ojo Posted July 6, 2009 Posted July 6, 2009 (edited) Thank you for the reply but ( "net use \\pascal /delete" ) will not work because it needs another parameter afterwards. for instance: ( "net use \\pascal\hd /del" )Hi, try this ( it's working on Win XP, you may have problems on Win 2000 or Vista): #include <array.au3> ; include is only needed for _arraydisplay, delete it if you don't need _arraydisplay Global $ar_networkconnection [26] ; array 4 NetworkConnections _GetNetworkConnection () ; Reading NetworkConnection from WMI _ArrayDisplay ($ar_networkconnection) ; Display Array Exit ; Delete Exit for DriveMapDel For $i = 0 to 26 if $ar_networkconnection [$i] <> "" Then DriveMapDel ($ar_networkconnection [$i]) ; Delete Shares you get from WMI Next Func _GetNetworkConnection () $i = 0 $strComputer = "Localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkConnection") For $objItem In $colItems if StringInStr ($objItem.RemoteName, "charlie-1") <> 0 Then ; If Servername charlie is in WMI Class Query, then fill array $ar_networkconnection [$i] = $objItem.LocalName $i += 1 EndIf Next EndFunc Edit: Because the stuff above is badly formatted, here is au3 file.netwokconn.au3 Edited July 6, 2009 by 99ojo
Tsiyoshi Posted July 6, 2009 Author Posted July 6, 2009 Hi, try this ( it's working on Win XP, you may have problems on Win 2000 or Vista): #include <array.au3> ; include is only needed for _arraydisplay, delete it if you don't need _arraydisplay Global $ar_networkconnection [26] ; array 4 NetworkConnections _GetNetworkConnection () ; Reading NetworkConnection from WMI _ArrayDisplay ($ar_networkconnection) ; Display Array Exit ; Delete Exit for DriveMapDel For $i = 0 to 26 if $ar_networkconnection [$i] <> "" Then DriveMapDel ($ar_networkconnection [$i]) ; Delete Shares you get from WMI Next Func _GetNetworkConnection () $i = 0 $strComputer = "Localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkConnection") For $objItem In $colItems if StringInStr ($objItem.RemoteName, "charlie-1") <> 0 Then ; If Servername charlie is in WMI Class Query, then fill array $ar_networkconnection [$i] = $objItem.LocalName $i += 1 EndIf Next EndFunc Edit: Because the stuff above is badly formatted, here is au3 file. Thanks a lot, this is the right direction except that the network drive is not deleted only shown in the arraydisplay. Do I need to add _arraydelete perhaps at the end?
99ojo Posted July 6, 2009 Posted July 6, 2009 (edited) Thanks a lot, this is the right direction except that the network drive is not deleted only shown in the arraydisplay. Do I need to add _arraydelete perhaps at the end?Hi,delete the exit after the _ArrayDisplay or mask it as remark. You should have read my remark after the exit line: Delete Exit for DriveMapDel. You can delete the _ArrayDisplay as well, it was only for debugging.If you delete the _ArrayDisplay you can delete also the include line.;-))Stefan Edited July 6, 2009 by 99ojo
Tsiyoshi Posted July 6, 2009 Author Posted July 6, 2009 Hi,delete the exit after the _ArrayDisplay or mask it as remark. You should have read my remark after the exit line: Delete Exit for DriveMapDel. You can delete the _ArrayDisplay as well, it was only for debugging.If you delete the _ArrayDisplay you can delete also the include line.;-))StefanThat's right, I missed the exit deletion ....it makes perfect sense now :-) Thanks a lot for you help, I appreciate it.
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