开发者

How do I remotely obtain a system's network shares and connections?

开发者 https://www.devze.com 2022-12-27 19:01 出处:网络
I\'m looking for a way to obtain information similar to the following console applications, remotely:

I'm looking for a way to obtain information similar to the following console applications, remotely:

  • net use
  • net share
  • netstat -ano

However, I need to be able to do this without running a 3rd party application on the system. This effectively rules out 开发者_如何学Cusing psexec to execute the command remotely, because psexec would then be installed as a service.

I should add that I have administrative credentials on the remote system. I've considered using WMI's remote execution ability, but that requires me to write output to a file and then retrieve it. It's possible, but I'd like to know if anyone has a better way.

I am using Delphi 2010.


there are a couple Delphi WMI components that allow remote access. I have not used the remote options personally though.

MagWmi - http://www.magsys.co.uk/delphi/magwmi.asp (Delphi 2010 support, and free with source)

WMISet/NTSet - http://www.online-admin.com/ntset.html (TNTShare Manages shared resources on a local computer and remote hosts. Using this component you can change list of shared devices, see files that have been opened by remote users, watch and terminate remote sessions opened to the destination computer, change list of mapped network drives. It is not free.)

GLibWMI - Found at Torry.net, home page not available. (Delphi 2010 support and Freeware with source). Not sure if its capable of remote access. I have not used it.

Hope this helps


I think the same as Logman.
You can access this information using WMI.

GLibWMI components can be found on this website (http://neftali.clubdelphi.com) or sourceforge (http://sourceforge.net/projects/glibwmi/).
The current version is 1.8b and has a component called SharedInfo with which you can get that information.
The source code is available so you can expand it to access other WMI classes if necessary.

Regards.
P.D: Sorry for my mistakes with english.


You can enumerate shares using the NetShareEnum function (headers are in the Jedi Apilib).

I assume there must be an api for the "net use" but I have never used it (check the WNet functions). Alternative is to use the EnumNetworkDrives method of the WshNetwork com object.

As for netstat I don't think it's possible to do that remotely (other than using some kind of method to spawn a process remotely).

0

精彩评论

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

关注公众号