views:

260

answers:

3

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 using 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.

+5  A: 

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

Logman
GLibWMI Library Components can be found on this website: * http://neftali.clubdelphi.com * Sourceforge (http://sourceforge.net/projects/glibwmi/)
Neftalí
+1  A: 

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).

Remko
+2  A: 

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.

alt text

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

Neftalí