Created On:  18 September 2012


Customer has COBOL application that resides on a network share.
He is starting the application from within a Windows batch file that also resides on the network share.

When his application starts it does a call to "CBL_GET_CURRENT_DIR" to return the name of the folder from which the application was started.
The application and batch file are on \\server1\myfolder.

When the batch file starts I get the following error:

       '%1' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory.'

and the program name cannot be found.

Why is this occurring?


The problem is that Windows does not allow for a .bat file to have a network share as its current directory so it automatically changes it to the Windows folder for the local drive.

This will work if you map a drive letter to the UNC name in which case the drive letter and folder will be returned in the call "CBL_GET_CURRENT_DIR.

You can also specify the following commands in your .bat file which will get the current folder name where the bat file was started.

echo %~dp0

If you use this with the pushd and popd commands in the .bat file it will automatically map a drive letter to the folder so that your application will run successfully.


I have a folder called \\server1\myfolder containing runit.bat and testgetdir.exe which is COBOL program which does CBL_GET_CURRENT_DIR and displays the returned value.

When I run runit.bat below from this location it maps a drive Z: and executes testgetdir.exe which successfully displays z:\myfolder.

set THISDIR=%~dp0
pushd %THISDIR%
popd %THISDIR%

If you just wanted to know where the .bat file was started you could read the content of environment variable THISDIR in your program using.

01 start-folder pic x(256) value spaces.
    DISPLAY "THISDIR" upon environment-name
    ACCEPT start-folder from environment-value