Vbs - 列出所有可见的Windows脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vbs - 列出所有可见的Windows脚本相关的知识,希望对你有一定的参考价值。
我试图列出所有可见的窗口(名称和顶部)。我的脚本运行良好,但需要安装Microsoft Word。要执行我的脚本,您可以运行此命令
Cscript -B myScript.vbs
Muskriptkvbs:
Dim console
Set console = WScript.StdOut
Dim myString
myString = ""
Set Word = CreateObject("Word.Application")
Set Tasks = Word.Tasks
Set colTasks = Word.Tasks
For Each Task in Tasks
If Task.Visible Then
If colTasks.Exists(Task.Name) Then
myString = myString & "@@##@@" & colTasks(Task.Name).Name & ","& colTasks(Task.Name).Top
End If
End If
Next
Word.Quit
console.WriteLine myString
你知道如何在没有安装Microsoft Word的情况下列出像myScript.vbs这样的可见窗口吗?
非常感谢
答案
我不认为这是可能的。但是,您可以列出所有正在运行的进程。
http://www.computerperformance.co.uk/vbscript/wmi_process.htm
' Process.vbs
' VBScript Win32_Process to discover which processes are running
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.4 - December 2010
' -------------------------------------------------------'
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "impersonationLevel=impersonate!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcess
strList = strList & vbCr & _
objProcess.Name
Next
WSCript.Echo strList
WScript.Quit
' End of List Process Example VBScript
以上是关于Vbs - 列出所有可见的Windows脚本的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 Messagebox 在 Windows 7 任务调度程序中启动 VBS 脚本?