开发者

C# Removing multiple disconnected IPC$ remote shares via "net use" command?

开发者 https://www.devze.com 2023-03-22 07:00 出处:网络
Issuing the \'Net Use\' command f开发者_StackOverflow中文版rom within the CMD prompt shows 50+ disconnected remote IPC$ shares in the following format:

Issuing the 'Net Use' command f开发者_StackOverflow中文版rom within the CMD prompt shows 50+ disconnected remote IPC$ shares in the following format:

where Name =

Status Local Remote Network


Disconnected \MACHINE\IPC$ Microsoft Windows Network

How do I enumerate through the list of these shares and kill them if I wanted to write a c# app to do so?

I read somewhere using WMI in conjunction with "win32_share" would work however, it's not returning the expected remote shares.

Any assistance on this would be greatly appreciated.

Thank you.


you must use the NetShareEnum WinApi function to get the list of shares and NetShareDel to remove the shared reources.

Here you have the Pinvoke for NetShareEnum with a sample and the NetShareDel as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号