Re: Display processes but not allow to move on until they are closed

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



kirkside wrote:

Dear Gurus,

I want to create a script that will display a specific list of
applications (processes) that are running, but not allow the user to
carry on untill all of the applications are closed.
Hi

Try this one with Notepad and IE running:

'--------------------8<----------------------
Set dicAppsList = CreateObject("Scripting.Dictionary")
dicAppsList.CompareMode = vbTextCompare

' key value is process name, item value is what is displayed to user
dicAppsList.Add "notepad.exe", "Notepad"
dicAppsList.Add "iexplore.exe", "Internet Explorer"

Set objWmi = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\.\root\cimv2")

Do
  strAppsRunning = ""  ' init value
  For Each strApp In dicAppsList
    Set colProcessList = objWmi.ExecQuery _
       ("Select * from Win32_Process Where Name = '" & strApp & "'")

    If colProcessList.Count > 0 Then
      strAppsRunning = strAppsRunning & dicAppsList.Item(strApp) & vbCrLf
    End If

  Next

  If strAppsRunning <> "" Then
    MsgBox "Please close the applications listed below" & vbCrLf _
         & "and then press OK to continue." & vbCrLf _
         & vbCrLf & strAppsRunning, _
           vbExclamation + vbSystemModal, "some title here"
  End If

Loop Until strAppsRunning = ""

WScript.Echo "Done"
'--------------------8<----------------------

--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
.



Relevant Pages

  • Re: Weird file name sorting order in folder explorer window
    ... Microsoft MVP Scripting and ADSI ... Is there any scripting way to make a folder ... explorer window display the file names in plain ASCII ascending order? ...
    (microsoft.public.scripting.vbscript)
  • Re: Script to check apps installed and remove unwanted apps
    ... >> I am trying to write a script that will remove Spyware applications ... actually "install" themselves the way well-behaved applications are supposed ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windows.server.scripting)
  • Re: Display a msgbos and not to wait
    ... > all this because using exec method, the application is totaly invisible for the user, and i want to display an info. ... Some nice progress bar examples by Joe Earnest: ... Microsoft MVP Scripting and WMI, ...
    (microsoft.public.scripting.vbscript)
  • Re: Display an acceptable use policy at logon?
    ... If you're OK with storing this acceptance in the registry I would recommend ... So what scripting language do you know or prefer? ... >>> I am trying to find a way to display an acceptable use policy to a user ... >>> I imagine that there could be something in the logon script that would ...
    (microsoft.public.windows.server.scripting)
  • Re: Running Applications from our Local Intranet page only?
    ... be able to open up applications they use a lot, ... you can script the instantiation of the Windows Scripting Host ... With the WSH object you can do anything that you could do ...
    (alt.html)