Skip to main content

Problem:

Is it possible to read the value of the MY DOCUMENTS folder in Windows?

Resolution:

The simplest method is to read the HOMEPATH environment variable from within your COBOL program as follows:

     working-storage section.

     01  ws-env-value                     pic x(255).

     procedure division.

         display "HOMEPATH" upon environment-name.

         accept ws-env-value from environment-value

            on exception

               display "HOMEPATH environment variable not found.".

         stop run.

Old KB# 1465