Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Executing a program in a new process from a Visual COBOL managed .NET application

Executing a program in a new process from a Visual COBOL managed .NET application

Problem:

Customer is developing a Windows Forms application in Visual COBOL for Visual Studio and they are looking for a way to start a non-COBOL executable like a text editor directly from within their application.

How can this be done?

Resolution

You can use the .NET framework Process class to execute all types of programs including .EXEs or to launch an application such as an editor by specifying just a filename to associate with it.

Look at the following link which provides some good examples:

http://www.dotnetperls.com/process-start

The following example will execute the text editor such as notepad that is associated with the .txt extension on your system and open up the file example.txt.

     $set ilusing"System.Diagnostics"
       class-id execprogram.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       working-storage section.
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
           invoke type Process::Start("example.txt")
           goback.
       end method.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-08-22 17:10
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.