Windows Vista Forums

show message when application is closed
  1. #1


    Sleb Guest

    show message when application is closed

    Hi,

    My question is regarding an application in a terminal server (win2k3). I
    want that when a particular application is closed that a message appear with
    a warning. The goal here is that this application needs to be open all the
    time so I want a warning message that appears saying not to close the
    application and not to log off but to disconnect. Putting the application as
    a service is not an option here.

    I think that by gpo, I can configure a message to appears when there is a
    log off but I am more concerned about the closing of the application.

    Anyone has an idea how this can be done?



    Thanks

      My System SpecsSystem Spec

  2. #2


    Pegasus [MVP] Guest

    Re: show message when application is closed


    "Sleb" <Sleb@newsgroup> wrote in message
    news:BD725594-3A57-4C7F-8EA0-1337A19998B6@newsgroup

    > Hi,
    >
    > My question is regarding an application in a terminal server (win2k3). I
    > want that when a particular application is closed that a message appear
    > with
    > a warning. The goal here is that this application needs to be open all the
    > time so I want a warning message that appears saying not to close the
    > application and not to log off but to disconnect. Putting the application
    > as
    > a service is not an option here.
    >
    > I think that by gpo, I can configure a message to appears when there is a
    > log off but I am more concerned about the closing of the application.
    >
    > Anyone has an idea how this can be done?
    >
    > Thanks
    Here is a script that will do it:
    [01] '-----------------------------------------------
    [02] 'Monitor when an application is closed.
    [03] 'Based on an idea by the Scripting Guy.
    [04] '-----------------------------------------------
    [05] iPoll = 5 'Time in seconds between polls
    [06] sProcess = "notepad" 'Name of application to be monitored
    [07] DQ = """"""
    [08]
    [09] Set oWMIService = GetObject("winmgmts:\\.\root\cimv2")
    [10] Set oWshShell = CreateObject("WScript.Shell")
    [11]
    [12] Set cMonitoredProcesses = oWMIService. _
    [13] ExecNotificationQuery("select * from __instanceDeletionEvent " _
    [14] & " within " & iPoll & " where TargetInstance isa 'Win32_Process'")
    [15]
    [16] Do
    [17] Set oProcess = cMonitoredProcesses.NextEvent
    [18] If InStr(oProcess.TargetInstance.CommandLine, sProcess) _
    [19] Then oWshShell.Run "msg.exe * ""The application " & DQ _
    [20] & sProcess & ".exe" & DQ & DQ & " was closed."""
    [21] Loop


    Instructions:
    1. Copy & paste the code into c:\Windows\ProcessMonitor.vbs.
    2. Unwrap lines that might have been wrapped around by your newsreader.
    3. Remove the line numbers.
    4. Save and close the file.
    5. Run the script.
    6. Open notepad.exe, wait 10 seconds, then close it. You should
    see a pop-up message.
    7. Press Ctrl+C to close the script.
    8. Adjust lines 5 and 6 to suit your environment.
    9. Invoke the script through your logon process.



      My System SpecsSystem Spec

  3. #3


    Sleb Guest

    Re: show message when application is closed

    Thank you very much.

    Regards

    "Pegasus [MVP]" wrote:

    >
    > "Sleb" <Sleb@newsgroup> wrote in message
    > news:BD725594-3A57-4C7F-8EA0-1337A19998B6@newsgroup

    > > Hi,
    > >
    > > My question is regarding an application in a terminal server (win2k3). I
    > > want that when a particular application is closed that a message appear
    > > with
    > > a warning. The goal here is that this application needs to be open all the
    > > time so I want a warning message that appears saying not to close the
    > > application and not to log off but to disconnect. Putting the application
    > > as
    > > a service is not an option here.
    > >
    > > I think that by gpo, I can configure a message to appears when there is a
    > > log off but I am more concerned about the closing of the application.
    > >
    > > Anyone has an idea how this can be done?
    > >
    > > Thanks
    >
    > Here is a script that will do it:
    > [01] '-----------------------------------------------
    > [02] 'Monitor when an application is closed.
    > [03] 'Based on an idea by the Scripting Guy.
    > [04] '-----------------------------------------------
    > [05] iPoll = 5 'Time in seconds between polls
    > [06] sProcess = "notepad" 'Name of application to be monitored
    > [07] DQ = """"""
    > [08]
    > [09] Set oWMIService = GetObject("winmgmts:\\.\root\cimv2")
    > [10] Set oWshShell = CreateObject("WScript.Shell")
    > [11]
    > [12] Set cMonitoredProcesses = oWMIService. _
    > [13] ExecNotificationQuery("select * from __instanceDeletionEvent " _
    > [14] & " within " & iPoll & " where TargetInstance isa 'Win32_Process'")
    > [15]
    > [16] Do
    > [17] Set oProcess = cMonitoredProcesses.NextEvent
    > [18] If InStr(oProcess.TargetInstance.CommandLine, sProcess) _
    > [19] Then oWshShell.Run "msg.exe * ""The application " & DQ _
    > [20] & sProcess & ".exe" & DQ & DQ & " was closed."""
    > [21] Loop
    >
    >
    > Instructions:
    > 1. Copy & paste the code into c:\Windows\ProcessMonitor.vbs.
    > 2. Unwrap lines that might have been wrapped around by your newsreader.
    > 3. Remove the line numbers.
    > 4. Save and close the file.
    > 5. Run the script.
    > 6. Open notepad.exe, wait 10 seconds, then close it. You should
    > see a pop-up message.
    > 7. Press Ctrl+C to close the script.
    > 8. Adjust lines 5 and 6 to suit your environment.
    > 9. Invoke the script through your logon process.
    >
    >
    >

      My System SpecsSystem Spec

  4. #4


    Pegasus [MVP] Guest

    Re: show message when application is closed

    Thanks for the feedback - I hope that the script worked for you.

    "Sleb" <Sleb@newsgroup> wrote in message
    news:EAC327A8-FD50-479E-A42F-C1B7317485DA@newsgroup

    > Thank you very much.
    >
    > Regards
    >
    > "Pegasus [MVP]" wrote:
    >

    >>
    >> "Sleb" <Sleb@newsgroup> wrote in message
    >> news:BD725594-3A57-4C7F-8EA0-1337A19998B6@newsgroup

    >> > Hi,
    >> >
    >> > My question is regarding an application in a terminal server (win2k3).
    >> > I
    >> > want that when a particular application is closed that a message appear
    >> > with
    >> > a warning. The goal here is that this application needs to be open all
    >> > the
    >> > time so I want a warning message that appears saying not to close the
    >> > application and not to log off but to disconnect. Putting the
    >> > application
    >> > as
    >> > a service is not an option here.
    >> >
    >> > I think that by gpo, I can configure a message to appears when there is
    >> > a
    >> > log off but I am more concerned about the closing of the application.
    >> >
    >> > Anyone has an idea how this can be done?
    >> >
    >> > Thanks
    >>
    >> Here is a script that will do it:
    >> [01] '-----------------------------------------------
    >> [02] 'Monitor when an application is closed.
    >> [03] 'Based on an idea by the Scripting Guy.
    >> [04] '-----------------------------------------------
    >> [05] iPoll = 5 'Time in seconds between polls
    >> [06] sProcess = "notepad" 'Name of application to be monitored
    >> [07] DQ = """"""
    >> [08]
    >> [09] Set oWMIService = GetObject("winmgmts:\\.\root\cimv2")
    >> [10] Set oWshShell = CreateObject("WScript.Shell")
    >> [11]
    >> [12] Set cMonitoredProcesses = oWMIService. _
    >> [13] ExecNotificationQuery("select * from __instanceDeletionEvent " _
    >> [14] & " within " & iPoll & " where TargetInstance isa
    >> 'Win32_Process'")
    >> [15]
    >> [16] Do
    >> [17] Set oProcess = cMonitoredProcesses.NextEvent
    >> [18] If InStr(oProcess.TargetInstance.CommandLine, sProcess) _
    >> [19] Then oWshShell.Run "msg.exe * ""The application " & DQ _
    >> [20] & sProcess & ".exe" & DQ & DQ & " was closed."""
    >> [21] Loop
    >>
    >>
    >> Instructions:
    >> 1. Copy & paste the code into c:\Windows\ProcessMonitor.vbs.
    >> 2. Unwrap lines that might have been wrapped around by your newsreader.
    >> 3. Remove the line numbers.
    >> 4. Save and close the file.
    >> 5. Run the script.
    >> 6. Open notepad.exe, wait 10 seconds, then close it. You should
    >> see a pop-up message.
    >> 7. Press Ctrl+C to close the script.
    >> 8. Adjust lines 5 and 6 to suit your environment.
    >> 9. Invoke the script through your logon process.
    >>
    >>
    >>


      My System SpecsSystem Spec

show message when application is closed problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
UCStream MFC Application stopped working and was closed phani kumar Live Mail 0 03 Apr 2010
Show VBScript error message in windows Form Application kaymaf VB Script 4 09 Oct 2009
Spooler Subsystem Application not working, stopped and Closed Oriwia Raureti General Discussion 0 16 Sep 2008
Fast Restore Application Stopped Working and Was Closed - HELP Motty_K General Discussion 5 13 Aug 2008
Annoying Windows message that cannot be closed David Vista performance & maintenance 0 28 Jan 2008