how would you call an .exe file from code behind a form?

jversusjjversusj Member Posts: 489
i searched the forum and could not find anything on this - please redirect me if i missed something.

on a button, i can set the properties for PushAction = RunSystem and RunCommand = path to an executable i'd like to run.

now, is is possible to instead put business logic behind the button (on the OnPush trigger for instance), so that one could do something like:
IF Company = US THEN call usa.exe.
IF company = DK THEN call denmark.exe
etc. etc.
essentially, the form would have a single button that calls a specific external application depending on which Naivision company the user is logged into.

i'm looking at the CAL help files but i do not see any commands to handle this - just references to the button properties. can anyone give me a hint on this? do i need to create a global of type file, and then somehow do a File.RUN or something?

thanks!
kind of fell into this...

Comments

  • BeliasBelias Member Posts: 2,998
    if GLOBALLANGUAGE = (usalanguageidentifier) then
      shell(mypathusa.exe);
    if GLOBALLANGUAGE = (deulanguageidentifier) then
      shell(mypathdeu.exe);
    

    languageidentifiers are fixed integers...find'em on google

    p.s.: never used but I think this works...try it...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • EvertPrinsEvertPrins Member Posts: 6
    You can have a look at the SHELL command in Navision.

    Here is an example of how you can use the SHELL function:

    SHELL('c:\joe\myprog.exe', 'arg1', 'arg2');
  • jversusjjversusj Member Posts: 489
    thank you both.

    all of our companies are operated in English - so i think i will lean towards following the "SHELL" recommendation. thanks.
    kind of fell into this...
  • BeliasBelias Member Posts: 2,998
    eheh..together...btw, you should toggle the property and put the code in onpush
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • jversusjjversusj Member Posts: 489
    yes! i got it to call my application! thank you. i knew there had to be some command...

    i got a pop-up saying "this is the first time you are calling
    file = generic.exe
    parameter =
    and it may not be trusted. proceed?" (paraphrased)

    this only happened the first time i ran this - wondering if this would pop up for every new user/machine to make the call or just this first time that i tried it?
    kind of fell into this...
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try this Tip & Trick to execute a program without Confirmation-link: Shell without confirmation-request of Navision 4.00
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • jversusjjversusj Member Posts: 489
    thank you all again. this looks like a nice solution. i have included it into my code and will hopefully get to test it soon.

    i apologize for not searching the forum for SHELL after being lead down that path. it is often too easy to continue the conversation in this thread instead of going back out to look for pre-existing answers.
    kind of fell into this...
  • krikikriki Member, Moderator Posts: 9,110
    To define which .exe to run, you might create an option in the Company-setup and then depending on that decide on the .exe to run. (or you might create a new setup-field in the company-setup with the .exe to run in it).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.