有一个VBScript (.vbs)脚本是有人在我公司做的。 它打开和closures某个应用程序,这个应用程序有一个托盘图标,每次它closures(通过控制台杀死)应用程序的托盘图标仍然存在。 因此,在运行该脚本一两天之后,应用程序的数百万个图标将保留在任务栏上。
是否有一个VBScript的指令,窗户刷新任务栏,摆脱这些图标?
这是scrpit:
***************************************************************************************** ' Progam Name: CheckConnection.vbs ' Program Purpose: This script check for an internec connection,the program pings to some domains,' wait some seconds (5 seconds) before the next try,if a domain is found,reset all counters,' and wait secondsBeforeNextCheck seconds before next check ' If the programs raise nMaxRetriesBeforeStartProgram then kill the program that ' manage the connection and start it again. ' Usage: This Script must be placed in ONE OF THE FOLLOWING PATHS ' 1) Start --> All Programs --> Start Up ' 2) HKLMSoftwareMicrosoftwindowsCurrentVersionRun ' 3)HKCUSoftwareMicrosoftwindowsCurrentVersionRun ' 4) Or you can create a task through: ' Start --> All Programs --> Accessories-->System Tools --> Scheduled Tasks--> Add Scheduled Task ' --> Follow the Wizard' ' 5) The program VZAccess Manager.exe must be configured to autoconnect through ' Tools --> Preferences --> WWan --> Connect Options --> Automatically Connect (this must be checked) ' 6) Also to autorefresh the ip the vzaccess manager.exe must be configured with an script when c onnect. ' Author: Benito Lopez ' Date: 06152009 ' Revision 1.1 : (11272009) -f was added to force the program VZAccess manager.exe to terminate. ' ***************************************************************************************** Dim WshShell Set WshShell = WScript.CreateObject("WScript.Shell") Dim objfso,objfile Set objfso = CreateObject("Scripting.FileSystemObject") Dim secondsBeforeNextCheck Dim strDomains(6) Dim nMaxRetriesBeforeStartProgram Dim nCounterRetries Const ForReading=1,ForWriting=2,ForAppending=8 strDomains (0) = "www.google.com" strDomains (1) = "www.yahoo.com" strDomains (2) = "www.chilpak.com" strDomains (3) = "www.microsoft.com" strDomains (4) = "www.flutec.com" strDomains (5) = "www.flutec.com.mx" strLogFilename = "c:checkconnectionlog.log" filepinger = "c:pingresult.log" nMaxRetriesBeforeStartProgram =5 secondsBeforeNextCheck = 60000 secondsBeforeNextTry = 15000 secondsBeforeAppStart = 2000 secondsAfterappStart = 60000 Call Main() Sub Main() set objfile = objfso.OpenTextFile(strLogFilename,8,True) WHILE 1 nCounterRetries = 0 FOR i = 0 TO 5 STEP 1 'Check the connection status if zero,means 'There is no internet connection or the domain is down If not IsThereInternetConnection(strDomains(i)) THEN 'Let suppose the domain is down,so we must try with the next domain nCounterRetries = nCounterRetries + 1 IF nCounterRetries >= nMaxRetriesBeforeStartProgram THEN 'Close the program targetprogram = "taskkill /im " & chr(34) & "VZAccess Manager.exe" & chr(34) & " /f" WshShell.Exec(targetprogram) 'Wait Applications Events 2 seconds Wscript.Sleep(secondsBeforeAppStart) 'Start the program targetprogram = chr(34) & "C:Program Filesverizon WirelessVZAccess ManagerVZAccess Manager.exe" & chr(34) & " -m" WshShell.Exec(targetprogram) 'Wait for the applications loads completely 1 seconds WScript.Sleep(secondsAfterappStart) 'Reset the counters nCounterRetries = 0 Wscript.Sleep secondsBeforeNextCheck END IF 'But we must wait some seconds before the next try Wscript.Sleep secondsBeforeNextTry ELSE 'If we get a reply from the current domain,'Everything is OK,The only we need to do is Wait until the next time to check 'Reset Counter nCounterRetries = 0 WScript.Sleep secondsBeforeNextCheck END IF NEXT Wend End Sub FUNCTION IsThereInternetConnection(strDomain) on error resume next 'Create some cons values 'Make the ping Dim strRun strRun = "%comspec% /c ping -n 1 " & strDomain & " > " & filepinger Dim objwss Set objwss = CreateObject("WScript.Shell") 'Hide the windows and wait the app to terminate WriteLog "Pinging " & strDomain & " ..." objwss.Run strRun,True Set objwss = nothing ''Read the ping Dim strotf Dim fso Dim otf strotf="" set fso = CreateObject("Scripting.FileSystemObject") set otf = fso.OpenTextFile(filepinger,ForReading) strotf = otf.ReadAll fso.DeleteFile filepinger set fso = nothing set otf = nothing 'Test the ping IF InStr(strotf,"Reply from")>0 THEN IsThereInternetConnection = TRUE ELSE IsThereInternetConnection = FALSE END IF WriteLog "Pinging Result " & IsThereInternetConnection & " Done." End FUNCTION Sub WriteLog(strLog) on error resume next Set objfile = objfso.GetFolder(strLogFilename) if objfile.size > 50000 then objfso.Close objfso.DeleteFile strLogFilename set objfile = objfso.OpenTextFile(strLogFilename,True) end if 'Add some useful @R_273_4045@ion strData = Now() & " - " objfile.WriteLine strData & strLog End Sub
如何通过vbs获取程序集版本
如何使用VBScript从文本文件读取?
如何使我的脚本便携式的VBS
如何在批处理或VBScript中使用通配符在registry中search密钥?
WMI查询错误为Win32_logonSession(Windows 2003)
我怎样才能隐藏特定的Windows更新?
访问被ShowFolderDetails for Documents拒绝
我怎样才能以VBScript,命令行或其他方式获得.m4v格式的电影的运行时间长度?
batch file中的Unicode字符
VBS和正则expression式
将鼠标指针移到系统托盘上的孤立图标将会消失。 我想这可以通过发送WM_MOUSEMOVE消息到系统托盘窗口以编程方式完成,但VBScript无权访问Windows API。
我建议你使用一些外部工具刷新系统托盘并从脚本中运行它。 例如,CodeProject上有一个TrayIconBuster实用程序,它可以每5秒清理一次托盘。 (但它需要.NET Framework。)或者你可以自己写一个类似的工具。
要从VBScript代码运行应用程序,可以使用WshShell.Run或WshShell.Exec方法。 你可以在你的脚本中找到例子。
使用VB调用一个BAT文件与重新启动资源管理器命令里面或REG文件
Windows注册表编辑器版本5.00 [ – HKEY_CURRENT_USER Software Microsoft Windows CurrentVersion Explorer TrayNotify]
程序告诉资源管理器放置或取下图标。 如果您与图标资源管理器进行交互,则会尝试通知程序执行任何操作,并通知它不在其中并删除图标。
Taskkill可以做两件事。 它可以要求关闭一个程序(程序可以打开一个对话框“保存文件? – 是/否/取消”),程序按照设计或使用关闭,而不用通知程序终止程序。该程序不能要求资源管理器删除图标。
尝试不带/f开关的Taskkill。 你可以随时调用它两次,然后用/f开关。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。