Start Gen Client Manager minimized or hidden in background
search cancel

Start Gen Client Manager minimized or hidden in background

book

Article ID: 259555

calendar_today

Updated On:

Products

Gen Gen - Host Encyclopedia Gen - Run Time Distributed Gen - Workstation Toolset

Issue/Introduction

How to start Gen 8.6 Client Manager (CM) process IEFCMN.EXE minimized or hidden in full background mode.
The objective is to hide the CM process to stop the user inadvertently closing it after it has been started.

Environment

Gen Client Manager

Resolution

Start CM Minimized
1a. Starting the CM from the desktop
The folder "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\CA\Gen 8.6" has Shortcut "Client Manager" whose Properties have "Run" set to "Normal window" which means that by default the CM window will be shown when it starts. To start the CM minimized simply requires changing "Run" to "Minimized" i.e.


b. The CM can also be started minimized from a command line using:
start /min "Any title" "C:\Program Files (x86)\CA\Gen86\Gen\IEFCMN.EXE" iefcm startup /initfile=iefcmn.ini
That command can therefore be used in any command file/batch script as required e.g. as part of the whole Gen GUI client application startup process.
(NOTE: "Any title" is required because "start" interprets first quoted parameter as a title so has a problem with the quoted path for IEFCM.EXE. The quotes path is required due to the fact that it contains spaces. Another option is to remove the path quotes and use 8.x DOS format i.e.
start /min C:\PROGRA~2\CA\Gen86\Gen\IEFCMN.EXE iefcm startup /initfile=iefcmn.ini)


Start CM in background
2. To start the CM completely hidden i.e. in full background requires starting it programmatically from another process.
These examples created by Gen Support after researching the web have been found to be successful.
NOTE: No official support is implied and these examples are used at own risk.

a. Visual Basic Script
Create script run_cm.vbs as follows:

Dim CMShell
Set CMShell = CreateObject("WScript.Shell")
CMShell.Run "C:\PROGRA~2\CA\Gen86\Gen\IEFCMN.EXE iefcm startup /initfile=iefcmn.ini", 0
Set CMShell = Nothing


By default .vbs files are normally run with wscript.exe i.e. the Microsoft ® Windows Based Script Host.
Therefore run_cm.vbs can be simply executed from Windows Explorer or from command line use "run_cm.vbs" or "wscript run_cm.vbs".

b. C/C++ program
Create sample C/C++ program run_cm.c as follows:

#include <windows.h>
#include <stdio.h>

int main()
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );
	
    si.dwFlags = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_HIDE;

    // Start the child process. 
    if( !CreateProcess(NULL,   // No module name (use command line)
        "C:\\Program Files (x86)\\CA\\Gen86\\Gen\\IEFCMN.EXE iefcm startup /initfile=iefcmn.ini",        // Command line
        NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        0,              // No creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory 
        &si,            // Pointer to STARTUPINFO structure
        &pi )           // Pointer to PROCESS_INFORMATION structure
    ) 
    {
        printf( "CreateProcess failed (%d).\n", GetLastError() );
        return;
    }
}


Web References:
https://learn.microsoft.com/en-us/windows/win32/procthread/creating-processes
https://learn.microsoft.com/en-us/windows/win32/procthread/setting-window-properties-using-startupinfo
https://stackoverflow.com/questions/46572646/createprocess-calling-cmd-exe-incl-arguments-with-no-showing-flashing-window
Set correct Visual Studio environment using command-line command: "%Gen86%\Gen\genenv.bat" 32 [vsver] (see doc for GENENV.BAT)
Compile and link run_cm.c with cl.exe i.e. run command "cl run_cm.c" to create run_cm.exe which can then be run from Windows Explorer or command line.
Potentially similar code can be used within a Gen GUI client application External Action Block or Inline Code if it is required to automatically start the CM from within the code when the application starts.

NOTES:
i. Both 2a and 2b will result in starting a IEFCMN.EXE process in background which is only visible in the Task Manager under the Processes tab (Background Processes) or the Details tab

To terminate the CM use the right mouse button on the "Client Manager (32 bit)" process and use option "End Task"

ii. If either program is executed a second time while IEFCMN.EXE is running it will simply result in the main CM window appearing in the desktop foreground.

iii. After the initial installation of the CM, before using either of the above programming options, for the first start it is recommended to start CM from the desktop to create the required iefcmn.ini and IEFCMN.SRV files (default directory %USERPROFILE%\AppData\Local\CA\Gen 8.6\cfg\cm), plus any target server configurations. In that way all configuration details will be properly saved on exit. (Client Manager Installation > First Start of Client Manager After Install)
Of course if any configuration details need to be changed in the future then desktop usage will also be required then.

Additional Information

NOTE: It is not possible to run the CM as a Windows service.
The option to run the CM as a service is not provided out of the box. Even if a CM service is implemented using some custom third party mechanism, although the CM will start successfully, when an application tries to use it problems will occur due to failures to access shared memory because it is being run as a service i.e. these messages will appear in the IEFCMN.LOG file:
===
02/08 14:53:24:686 TID:12156  OpenFileMapping( :SHAREMEM:IEFCOM:CLIENT/PID1108.MEM ) failed:  2
02/08 14:53:24:686 TID:12156  OpenEvent(:SEM:IEFCOM:CLIENT/PID1108.SEM) error 2 (0x2)
02/08 14:53:24:967 TID:12156  OpenFileMapping( :SHAREMEM:IEFCOM:CLIENT/PID7472.MEM ) failed:  2
02/08 14:53:24:967 TID:12156  OpenEvent(:SEM:IEFCOM:CLIENT/PID7472.SEM) error 2 (0x2)
===