Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 583719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:49:20+00:00 2026-05-13T14:49:20+00:00

There is a VBScript (.vbs) script that someone made here at my company. It

  • 0

There is a VBScript (.vbs) script that someone made here at my company. It opens and closes certain application, this application has a tray Icon and each time it closes (kills via console) the application the tray icon remains. So after one or two days running the script millions of icons of the application remain on the taskbar.

Is there an instruction in VBScript for windows to refresh the task bar and get rid of these icons?

Here is the 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) HKLM\Software\Microsoft\Windows\CurrentVersion\Run
'   3)HKCU\Software\Microsoft\Windows\CurrentVersion\Run
'   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 Files\Verizon Wireless\VZAccess Manager\VZAccess 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,0,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, 8,True)
    end if
    'Add some useful information
    strData = Now() & " - "
    objfile.WriteLine strData & strLog
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:49:20+00:00Added an answer on May 13, 2026 at 2:49 pm

    Orphan icons in the system tray go away after you move the mouse pointer over them. I guess this can be done programmatically by sending the WM_MOUSEMOVE message to the system tray window, but VBScript doesn’t have access to Windows API.

    I suggest that you use some external utility that refreshes the system tray and run it from your script. For example, there’s the TrayIconBuster utility on CodeProject, which can clean up the tray every 5 seconds. (But it requires .NET Framework.) Or you could write a similar tool yourself.

    To run an application from VBScript code, you can use the WshShell.Run or WshShell.Exec method. You can find examples in your script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 371k
  • Answers 371k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I will preface this by saying that sharepoint is a… May 14, 2026 at 7:00 pm
  • Editorial Team
    Editorial Team added an answer Functionally all i want is to determine the maximum size… May 14, 2026 at 7:00 pm
  • Editorial Team
    Editorial Team added an answer @Pop's answer gave me a clue & I modified the… May 14, 2026 at 7:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.