VBScript utility that will close all Reflection Desktop sessions

  • 7023225
  • 27-Jul-2018
  • 02-Aug-2018

Environment


Reflection Desktop (including Pro, for X, for IBM, or for UNIX and OpenVMS) 16.1 and later

Situation

It is easy to start Reflection using the command-line (or .bat file) to run Attachmate.Emulation.Frame.exe and supplying the name of a session document. But how to stop all sessions started like that might not be so apparent. This VBScript provides a quick automated method of closing all Reflection Workspace windows. It will close all separate Classic-UI Reflection windows, and all Reflection Workspace Ribbon-UI windows that may have multiple sessions running.

Resolution

  1. Create and save a new text file named CloseAll.vbs.
  2. Open CloseAll.vbs in Notepad, and copy the VBScript code below to it.
  3. Save, and close Notepad.
  4. To run, just double-click CloseAll.vbs, or you can run it from a .bat file.

'''''''''''''''''''''''''''''''''''''''''''''''''
' CloseAll.vbs
'
' VBScript to close all sessions in all Reflection
' Workspace windows. This works as long as the default
' "AutomationServerName" has not been changed from the
' default value of "Reflection Workspace".
'
' Example code provided without warranty or support.
' Please review and understand it before running.
''''''''''''''''''''''''''''''''''''''''''''''''''
const CloseAlwaysSave = 3
dim reflection
on error resume next
do while true       
   set reflection = GetObject("Reflection Workspace")
   if err = 0 then     
      reflection.Close CloseAlwaysSave
      Wscript.Sleep 1000 'wait 1 second to give R a chance to close
   else      
      err.clear     
      exit do     
   end if  
loop