Jump to content

How to delete specific network drives


Recommended Posts

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.

Link to comment
Share on other sites

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.

if folder is behinde maped drive you can use

DirRemove("Y:\Test1", 1) to delite folder in maped drive

or 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 connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 
Link to comment
Share on other sites

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 by 99ojo
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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 by 99ojo
Link to comment
Share on other sites

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

That's right, I missed the exit deletion ....it makes perfect sense now :-) Thanks a lot for you help, I appreciate it.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...