我需要一些帮助,以便在最初看起来像一个非常简单的要求.
我必须找到一种在Windows PC上循环打开应用程序的方法,目的是在安装在墙上的大屏幕上一次显示30秒的窗口.通常会有MS Access报告和几个网页.
我最初的想法是,我可以在PC上手动打开这些应用程序,然后运行VBScript来循环它们.但是这有两个问题.
任何人都可以建议我如何使用Windows(XP向上)机器上已有的资源实现这一目标?
在WHS中转出VBScript是可行的方法.这似乎有效.
'****************************************************************************************
' Script Name: ApplicationCycler.vbs
' Author: Ian Burns
' Date: 2 Dec 2011
' Description: VBScript for Windows Scripting Host. Cycles through any applications
' visible in the Task Bar giving them focus for a set period.
' Usage: Save file to Desktop and double click to run. If it isn't already running,
' it will start. If it is already running, it will stop.
'*****************************************************************************************
Option Explicit
Dim wshShell
Dim wshSystemEnv
Dim strComputer
Dim objWMIService
Dim colProcessList
Dim objProcess
Dim intSleep
' Loop lasts 5 seconds
intSleep = 5000
Set wshShell = CreateObject("WScript.Shell")
' Volatile environment variables are not saved when user logs off
Set wshSystemEnv = wshShell.Environment("VOLATILE")
' Check to see if the script is already running
If len(wshSystemEnv("AlreadyRunning")) = 0 Then
' It isn't, so we set an environment variable as a flag to say the script IS running
wshSystemEnv("AlreadyRunning") = "True"
' Now we go into a loop, cycling through all the apps on the task bar
Do
' Simulate the Alt+Esc keypress
wshShell.SendKeys "%+{Esc}"
Wscript.Sleep intSleep
Loop
Else
' It IS already running so kill any or all instances of it
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'WScript.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
' Delete the environment variable
wshSystemEnv.Remove("AlreadyRunning")
' Tidy up
Set wshSystemEnv = Nothing
Set wshShell = Nothing
Set objWMIService = Nothing
Set colProcessList = Nothing
End If
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13512 次 |
| 最近记录: |