Change the Navision4.00 work directory

mariacafemariacafe Member Posts: 7
Hi all,
When you execute from Navision 4.00 one of the functions listed below, you change the Navision Work Directory (for example C:\Program Files\Microsoft Business Solutions-Navision 4\Client>) with the new directory you select for these functions (for example C:\Navision License> or C:\Picture> etc...).

List of Function that change the Navision Work Directory:
* Tools - License Informations - Change
* (From Navigation Pane) Administration - Application Setup - General - Company Information - Button "Picture" - Import...
* (From Navigation Pane) Administration - Application Setup - General - Company Information - Button "Picture" - Export...
* (From Navigation Pane) Financial Management - General Ledger - Budgets - Button "Functions" - Import from Excel...

To see the current work directory, I've put this statement into the "On Run" event of a new code-unit:
SHELL('c:\windows\system32\cmd.exe');
So:
1) Try to run this code-unit from Object Designer, and you see a dos prompt of the current work directory.
2) Then try to execute one of the functions I wrote before.
3) Then execute the new code-unit again, and you see the work directory changed.

I need a way to set the work directory before I execute every Shell statement from Navision C/AL, because I've an application that needs to work in the original Navision 4.00 Work Directory even if the other application change this work Directory.
Can you help me?

Thanks in advance
:D
Maria

Comments

  • krikikriki Member, Moderator Posts: 9,118
    I think of 2 possibilities:

    1) Make a shortcut for the fin.exe (or finsql.exe) and put the working directory in there.

    2) When launching an external program, in stead of launching it directly, you make a batch file that you launch. And in the batchfile you change the subdirectory and then you launch the program from the batch.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Navi_LearnerNavi_Learner Member Posts: 356
    My Navison windows is locked and the menu bar and its related forms and reports and everything goes to the right i.e. it occupied the whole windows screen and I can't even open any forms. I try all the way, but it still doesn't work. Can anyone help? Thanks in advance!
  • krikikriki Member, Moderator Posts: 9,118
    My Navison windows is locked and the menu bar and its related forms and reports and everything goes to the right i.e. it occupied the whole windows screen and I can't even open any forms. I try all the way, but it still doesn't work. Can anyone help? Thanks in advance!

    see http://www.mibuso.com/forum/viewtopic.php?t=8008

    PS : It would have been better creating a new topic instead of replying to this topic that is about something else
    PS2 : next time try also to search the forum. Most of the time, the problem is already solved
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • mariacafemariacafe Member Posts: 7
    Thank you Alain,
    I would use your second possibility but I don't know how to get the current work directory from Navision to set in the batchfile.

    Thank you
    Maria
    Maria
  • krikikriki Member, Moderator Posts: 9,118
    mariacafe wrote:
    I would use your second possibility but I don't know how to get the current work directory from Navision to set in the batchfile.
    I don't know if there is a better way. But here a 2 ways:

    When entering in Navision, (eg in Codeunit1) you have to save the current path. How to do it:
    recSession.RESET;
    recSession.SETRANGE("My Session",TRUE);
    recSession.FIND('-');
    IF SHELL(ENVIRON('windir') + '\system32\cmd.exe','/C cd >' + ENVIRON('temp') + '\' + FORMAT(recSession."Connection ID")) = 0 THEN BEGIN
      // open the file ENVIRON('temp') + '\' + FORMAT(recSession."Connection ID") and read the first line. This line contains the current path of Navision (if you have set the working directory in the shortcut of Navision and if you want to open a local DB, you have to put it also in the shortcut)
    END;
    

    Another possibility (maybe better) is that you set the Navision-path in a setup.
    Or if you have different Navision-paths (depending on the computer), make a table like this:
    Table "Navision Path"
    Field10:"Computer Name":Text50 (Primary key field, can be blank to have a default for all computers)
    Field20:"Navision Path":Text250

    How to get the correct record:
    IF NOT "Navision Path".GET(ENVIRON(COMPUTERNAME)) THEN
      "Navision Path".GET('');
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • krikikriki Member, Moderator Posts: 9,118
    Other method (thanx to fb =D> ).
    see http://www.mibuso.com/forum/viewtopic.php?p=33673#33673
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.