如何远程获取系统的网络共享和连接?
我正在寻找一种方法来远程获取类似于以下控制台应用程序的信息:
- net use
- net share
- netstat -ano
但是,我需要能够在系统上运行第 3 方应用程序的情况下执行此操作。这有效地排除了使用 psexec 远程执行命令,因为 psexec 将作为服务安装。
我应该补充一点,我在远程系统上拥有管理凭据。我考虑过使用 WMI 的远程执行能力,但这需要我将输出写入文件,然后检索它。这是可能的,但我想知道是否有人有更好的方法。
我使用的是德尔福2010。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有几个 Delphi WMI 组件允许远程访问。不过我个人还没有使用过远程选项。
MagWmi - http://www.magsys.co.uk /delphi/magwmi.asp(Delphi 2010 支持,并且免费提供源代码)
WMISet/NTSet - http://www.online-admin.com/ntset.html (TNTShare
管理本地计算机和远程主机上的共享资源。使用此组件,您可以更改共享设备列表、查看远程用户打开的文件、监视和终止向目标计算机打开的远程会话、更改映射网络驱动器列表。它不是免费的。)
GLibWMI - 在 Torry.net 上找到,主页不可用。 (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
我认为与 Logman 相同。
您可以使用WMI访问此信息。
GLibWMI 组件可以在此网站上找到 (http://neftali.clubdelphi.com) 或 sourceforge (http://sourceforge.net/projects/glibwmi/)。
当前版本是 1.8b,有一个名为 SharedInfo 的组件,您可以使用它获取该信息。
源代码可用,因此您可以根据需要对其进行扩展以访问其他 WMI 类。
问候。
PD:很抱歉我的英语错误。
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.
您可以使用 NetShareEnum 函数枚举共享 (标题位于 Jedi Apilib 中)。
我假设必须有一个用于“网络使用”的 api,但我从未使用过它(检查 WNet 函数)。另一种方法是使用 EnumNetworkDrives 方法WshNetwork com 对象的。
至于 netstat 我认为不可能远程执行此操作(除了使用某种方法远程生成进程之外)。
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).