Highlighted
Absent Member.
Absent Member.
1898 views

Hide a CMD window in a Visual COBOL native app

Jump to solution

[Migrated content. Thread originally posted on 25 October 2011]

Hello,

I want to execute a system command from a native app which I am migrating from RM/COBOL for Windows. This execution in particular looks like this in RM:

CALL "C$GUICFG" USING "System window type=hidden " Z9.
STRING 'CMD /C/S ECHO ' MENSA ' >> \VPC\OUT\ET'
DELIMITED SIZE INTO MANDATO.
CALL "SYSTEM" USING MANDATO.
CALL "C$GUICFG" USING "System window type=show " Z9.


C$GUICFG was used in this case for hidding the new window. Do you know how to obtain the same behaviour in the Visual COBOL version?

Regards
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Hide a CMD window in a Visual COBOL native app

Jump to solution
Something like the following should work:


       identification division.
       program-id. Program1.
       data division.
       working-storage section.
       01 command-line pic x(100).
       01 command-line-len pic x(4) comp-5. 
       01 run-unit-id    pic x(8) comp-5.
       01 stack-size     pic x(4) comp-5. 
       01 flags          pic x(4) comp-5. 
       01 status-code    pic x(4) comp-5.
       01 any-key        pic x.
       01 comspec        pic x(200)  value spaces.
       procedure division.
           
           display "COMSPEC" upon environment-name
           accept comspec from environment-value
           
           string comspec delimited by " "
              " /C echo ' MENSA '>>testfile.txt"
                 delimited by size
              into command-line
           end-string
             
           move length of command-line to command-line-len
           move 1 to flags   

           call "CBL_EXEC_RUN_UNIT"
              using by reference command-line
                    by value     command-line-len
                    by reference run-unit-id
                    by value     stack-size
                    by value     flags
              returning    status-code
           end-call

           accept any-key
           stop run.

View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Hide a CMD window in a Visual COBOL native app

Jump to solution
Something like the following should work:


       identification division.
       program-id. Program1.
       data division.
       working-storage section.
       01 command-line pic x(100).
       01 command-line-len pic x(4) comp-5. 
       01 run-unit-id    pic x(8) comp-5.
       01 stack-size     pic x(4) comp-5. 
       01 flags          pic x(4) comp-5. 
       01 status-code    pic x(4) comp-5.
       01 any-key        pic x.
       01 comspec        pic x(200)  value spaces.
       procedure division.
           
           display "COMSPEC" upon environment-name
           accept comspec from environment-value
           
           string comspec delimited by " "
              " /C echo ' MENSA '>>testfile.txt"
                 delimited by size
              into command-line
           end-string
             
           move length of command-line to command-line-len
           move 1 to flags   

           call "CBL_EXEC_RUN_UNIT"
              using by reference command-line
                    by value     command-line-len
                    by reference run-unit-id
                    by value     stack-size
                    by value     flags
              returning    status-code
           end-call

           accept any-key
           stop run.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Hide a CMD window in a Visual COBOL native app

Jump to solution
It works a treat! Thank you!
0 Likes
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.