Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
Yes, please take a look at the docs for library routine CBL_GET_CURRENT_DIR here:
Thanks.
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
That was perfect! Thank you!
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
Sorry to ressurect the topic but...will this work to obtain a network path, without mounting a network drive? I did some testing calling the program trough a batch file, wile acessing the path trough explorer and the batch file returned a UNC path error. The only workaround was mounting a drive with the desired path.
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
CBL_GET_CURRENT_DIR will return a network path name if that is the current folder for the process.
You do not need to map a driver letter if that is what you are asking but the drive must be accessible.
For example, I just wrote a test program that calls this function and displays the directory-name and return code from the call.
I placed it on a network drive called \\\\myserver\\testdir and executed it there through Windows Explorer and it returned "\\\\myserver\\testdir".
If I mapped drive letter Z to this folder then it returned "Z:\\" instead.
Is this what you are asking?
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
Yes,so the problem lies with calling the batch file through explorer, not the cobol program through explorer. Will it make a diference wheter i'm calling an .exe or a .gnt?
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
How are you calling the COBOL program?
COBOL .EXE programs are standard Windows applications and can run standalone.
A .GNT needs a trigger program to start it like the RUN.EXE or RUNW.EXE triggers supplied with Net Express. (or your own .EXE trigger)
so myapp.exe is started with
myapp
while myapp.gnt is started with
run myapp.gnt
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
I"m calling run myapp.gnt trough a batch file
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
This should work fine as long as the system has access to the bin folder which contains RUN.EXE and the COBOL run-time files.
What is the actual task that you are trying to accomplish and what is the problem you are experiencing?
Thanks.
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
My objective is to obtain the current folder wich the program is running, so i can dinnamicaly alter the file path.
I have my programs at \\\\server\\programs
Files are at \\\\server\\counting
At \\counting we have the batch files that gonna call my .gnt or .exe (i'm testing with both)
What i have observed
If i access \\\\server\\counting\\bat001.bat, as it opens shows me the following message
'%1' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory.'
and continues.. when it enters my cobol program, it does not obtain the correct path (\\\\server\\counting), instead it gives me the default windows directory. - This was solved since i'm going to do this on a domain, this problem does not occur.
But i cannot obtain the \\\\server\\counting path, since i'm running the exe on \\\\server\\programs.
Therefore i assume that for this to work the program should be on \\\\server\\counting, or i'm wrong?
Is there a way to obtain the path in wich my files are without the program being on the same folder?
Is there a way to obtain the folder wich i'm running an application?
I have a program that is being used in two different folders. It uses the same logic for both, but i can't mix it's files.
Altering the programs to select wich folder to run is not a option. I need to do this without user input.
Thanks in advance
Yes, 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.
I found that you can 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.
Example:
I have a folder called \\\\server\\myfolder containing runit.bat and testgetdir.exe which is COBOL program which does cbl_get_current_dir and displays 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%
testgetdir.exe
popd %THISDIR%
pause
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