can we put a button inside nav then can run outside program?

julkifli33julkifli33 Member Posts: 1,092
edited 2013-08-14 in NAV Three Tier
hi all
i have develop program using VSTO 2010
and then create shortcut desktop on every user PC
now..can we put a button inside nav then can run outside program?
thanks

Comments

  • postsauravpostsaurav Member Posts: 708
    Hi,

    Here is that it can be done.

    I created a Form where i created a button and Onpush of that button i call a function that executes the program.

    RVal := RunExeFromNAV('notepad.exe',1,TRUE);

    Where
    RVal - ReturnValue From Function (GlOBAL Integer Variable).
    RunExeFromNAV Is Function.

    Here is the Function -

    PROCEDURE RunExeFromNAV@1102153000(CompletePath@1102153000 : Text[1024];WindowStyle@1102153001 : Integer;EOC@1102153002 : Boolean) OintReturnValue : Integer;
    VAR
    Laut@1102153005 : Automation "{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} 1.0:{72C24DD5-D70A-438B-8A42-98424B88AFB8}:'Windows Script Host Object Model'.WshShell"; ('Windows Script Host Object Model'.WshShell)
    Lint@1102153004 : Integer;
    BEGIN
    CREATE(Laut);
    OintReturnValue := Laut.Run(CompletePath,WindowStyle,EOC);
    CLEAR(Laut);
    END;

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • julkifli33julkifli33 Member Posts: 1,092
    postsaurav wrote:
    Hi,

    Here is that it can be done.

    I created a Form where i created a button and Onpush of that button i call a function that executes the program.

    RVal := RunExeFromNAV('notepad.exe',1,TRUE);

    Where
    RVal - ReturnValue From Function (GlOBAL Integer Variable).
    RunExeFromNAV Is Function.

    Here is the Function -

    PROCEDURE RunExeFromNAV@1102153000(CompletePath@1102153000 : Text[1024];WindowStyle@1102153001 : Integer;EOC@1102153002 : Boolean) OintReturnValue : Integer;
    VAR
    Laut@1102153005 : Automation "{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} 1.0:{72C24DD5-D70A-438B-8A42-98424B88AFB8}:'Windows Script Host Object Model'.WshShell"; ('Windows Script Host Object Model'.WshShell)
    Lint@1102153004 : Integer;
    BEGIN
    CREATE(Laut);
    OintReturnValue := Laut.Run(CompletePath,WindowStyle,EOC);
    CLEAR(Laut);
    END;

    Hi postsaurav,
    thanks for the sharing
    any txt file that i can test in my own?
  • casanovacasanova Member Posts: 194
    how about in NAV 2013 ?
    there is no SHELL anymore

    according this link --> http://msdn.microsoft.com/en-us/library/dd355282.aspx
    only for 2009
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Did you check Automation 'Windows Script Host Object Model'.WshShell?
  • casanovacasanova Member Posts: 194
    Did you check Automation 'Windows Script Host Object Model'.WshShell?
    mohana thx
    now can execute
    =D>

    but is there a way if i want to send parameter (company name for example) ??
    where should i put parameter?
    ObjectPath := '\\Servername\tmp\Debug\File.exe';
    RunModally := FALSE;
    DummyInt := 1;
    
    CREATE(WshShell,FALSE,TRUE);
    WshShell.Run(ObjectPath,DummyInt,RunModally);
    CLEAR(WshShell);
    
  • thegunzothegunzo Member Posts: 274
    This dotnet method works for me
    OBJECT Codeunit 50125 Test Process
    {
      OBJECT-PROPERTIES
      {
        Date=14.08.13;
        Time=07:20:59;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnRun=BEGIN
                Process := Process.Process;
                ProcessStartInfo := ProcessStartInfo.ProcessStartInfo('c:\Windows\notepad.exe');
                ProcessStartInfo.Arguments := 'c:\temp\SalesPurchDocRenumering.txt';
                Process.Start(ProcessStartInfo);
              END;
    
      }
      CODE
      {
        VAR
          Process@1000000000 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.Process" RUNONCLIENT;
          ProcessStartInfo@1000000001 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.ProcessStartInfo" RUNONCLIENT;
    
        EVENT Process@1000000000::OutputDataReceived@89(sender@1000000001 : Variant;e@1000000000 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.DataReceivedEventArgs");
        BEGIN
        END;
    
        EVENT Process@1000000000::ErrorDataReceived@90(sender@1000000001 : Variant;e@1000000000 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.DataReceivedEventArgs");
        BEGIN
        END;
    
        EVENT Process@1000000000::Exited@91(sender@1000000001 : Variant;e@1000000000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.EventArgs");
        BEGIN
        END;
    
        EVENT Process@1000000000::Disposed@92(sender@1000000001 : Variant;e@1000000000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.EventArgs");
        BEGIN
        END;
    
        BEGIN
        END.
      }
    }
    
    
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
Sign In or Register to comment.