How to Get Client Folder

tramireztramirez Member Posts: 4
Hye,

Do you know how can I get the Folder where I'm executing the client (fin.exe or finsql.exe)?

If in one computer I have Two installations of Navision with the same version in two diferents folders:
c:\Program Files\Micorosft Business Solutions-Navision\Client 1\
c:\Program Files\Micorosft Business Solutions-Navision\Client 2\

How can I know wich Client has ran mi application?

I need to do this because I have one file saved in BLOB format in a Navision Table, and I need to export it (in runtime) in the Client folder.

So I need to know witch is the client folder, cause is possible that the instalation is not in the default path.

Any suggestions? :roll:

Thanks a lot!!

Comments

  • WaldoWaldo Member Posts: 3,412
    I'm afraid this is not possible. In C/SIDE, you dont' have enough process information to do this. I checked the virtual tables an the system methods, but nothing seems useable.

    If you had a process ID, it would be possible to find the working folder or path to exe using a custom made Automation control.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Try deleting the folder while Navision is running. If it's in use, it'll give you an error.
  • DenSterDenSter Member Posts: 8,307
    yeah and if it is not in use, you'll only lose your NAV installation folder :mrgreen:
  • ara3nara3n Member Posts: 9,258
    lol. Well he had a good idea, which I'll try to improve.

    How about try to copy the executable from that location to a temp location and delete the executable and copy it back if you succeed.

    One question I have though is why does he want to move it to Navision directory?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • WaldoWaldo Member Posts: 3,412
    DenSter wrote:
    yeah and if it is not in use, you'll only lose your NAV installation folder :mrgreen:

    :D =D>

    Ara3n. Question is: how can you get the folder where the executable is located? You would put it in a setup table?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • ara3nara3n Member Posts: 9,258
    You would search through the virtual file table and search for fin.exe. Or you could put a computer + User setup table.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • WaldoWaldo Member Posts: 3,412
    For performance reasons, I would go for the second one...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • ara3nara3n Member Posts: 9,258
    well Once you find it the first time, you don't need to search again. You would put in the setup table.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • WaldoWaldo Member Posts: 3,412
    Ah, combination of the two ... nice.

    Tramirez ... I think you almost have a solution.

    =D>

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • garakgarak Member Posts: 3,263
    edited 2006-10-21
    My Solution is

    Write an programm with vb, c# or wsh (wsh / WMI should be do this) to analyse the processes. Serach in the processes for fin.exe or finsql.exe. When you found the programm, you can get the process properties (like installation folder) and send it back to navision (for example as stream)

    see next post.

    Regards
    Do you make it right, it works too!
  • garakgarak Member Posts: 3,263
    edited 2006-10-23
    OK, so i've enougth time yet (came from an party) and i wrote now this little application:

    Code for WMI Script that you must call from Navision
    Set wmi = GetObject("winmgmts://./root/cimv2")
    
    wql = "select * from win32_process where name='finsql.exe'"
    Set result = wmi.ExecQuery(wql)
    
    For each prozess in result
      WSHShell.echo "Prozessname " & Prozess.Name
      WSHShell.echo "ExPath = " & Prozess.ExecutablePath
    Next
    

    Here the navision code
    IF EXISTS('D:\NavZUPs\GetExecuteFolder.vbs') THEN BEGIN
      IF ISCLEAR(WSHShell) THEN
        CREATE(WSHShell);  //WSHShell.Currentdirectory should also work (not tested)
    
      WSHExec := WSHShell.Exec('cscript D:\NavZUPs\GetExecuteFolder.vbs');
      
      WHILE NOT WSHExec.StdOut.AtEndOfStream DO BEGIN
        ExecFolder := WSHExec.StdOut.ReadALL;
        ExecFolder := copystr(ExecFolder,Strpos(ExecFolder,'ExPath = '),strlen(ExecFolder));
      END;
    end;
    

    The DOS - Prompt you can prevent when you call the vbs with parameter (no window)

    Regards

    So, good night. My bed calls.
    Oh, my head, some of this beers was bad :-(
    Do you make it right, it works too!
  • garakgarak Member Posts: 3,263
    There is an other way to solved this problem:

    Make to Shortcuts on your desktop.
    First to Client one
    Second to Client two

    In first shortcut you insert parameter id=%userprofile%\Client1.zup
    and in the second id=%userprofile%\Client2.zup

    with commandline you can get the parameters.
    If you found client1.zup your application runs from folder
    "c:\Program Files\Micorosft Business Solutions-Navision\Client 1\"
    if you found client2.zup your application runs from folder
    "c:\Program Files\Micorosft Business Solutions-Navision\Client 2\"

    Regards
    Do you make it right, it works too!
  • WaldoWaldo Member Posts: 3,412
    garak wrote:
    Oh, my head, some of this beers was bad :-(
    I bet it were the last ones :wink:

    With the last post:
    How are you going to get from Navision which ZUP-file you're using?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • garakgarak Member Posts: 3,263
    It was the last :!: But the others are delicious :o

    How i going to get which zup file i'm using :?:

    I use (F5) System \ Commandline <- gives the start parameter like database, server, company and id (id is the place where i store the zup)

    Regards
    Do you make it right, it works too!
  • WaldoWaldo Member Posts: 3,412
    Never used it, never needed it, but definitally nice to know. Learned something new.

    Thanks!

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • kinekine Member Posts: 12,562
    WsShell: Automation 'Windows Script Host Object Model'.WshShell
    
    CREATE(WsShell);
    MESSAGE('%1',WsShell.CurrentDirectory);
    

    As you can see, if you do not change the current directory, you can get the App folder through this. Because if you create shortcut for the .exe file, the default dir is the app dir.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.