使用 COM 自动化 Windows 及相关应用
在 Windows 系统中,COM(Component Object Model)提供了强大的自动化功能,可用于操作 Windows 自身的基本元素、网络应用、办公软件等。下面将详细介绍如何使用 COM 进行各种自动化操作。
1. 使用 Shell.Application 类自动化 Windows 资源管理器
- 创建 Shell.Application 对象实例:
PS (3) > $shell = new-object -com Shell.Application- 查看对象成员:
PS (4) > $shell | gm以下是部分成员列表:
| 名称 | 成员类型 | 定义 |
| ---- | ---- | ---- |
| AddToRecent | Method | void AddToRecent (Variant, st…) |
| BrowseForFolder | Method | Folder BrowseForFolder (int, …) |
| CanStartStopService | Method | Variant CanStartStopService (…) |