Shell command with parameters from RTC

sbssbs Member Posts: 27
edited 2013-02-05 in NAV Three Tier
Hi

I want to call a shell command from RTC with parameters.

I found this thread
viewtopic.php?f=32&t=31440

But unforturnately I am using 2009 sp1, so dotnet is not an option :(

Answers

  • kinekine Member Posts: 12,562
    And why not to upgrade to NAV 2009R2? It is just another hotfix for SP1...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • yukonyukon Member Posts: 361
    Hi sbs,

    Please try with below code.
    OBJECT Codeunit 55000 WshShellRun
    {
      OBJECT-PROPERTIES
      {
        Date=02/06/13;
        Time=10:23:58 PM;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnRun=BEGIN
              END;
    
      }
      CODE
      {
    
        PROCEDURE fnWshShellRun@1000000000(ptxtCommand@1000000002 : Text[1024];ptxtParameter@1000000004 : Text[1024];pintWindowStyle@1000000001 : Integer;pblnWaitOnReturn@1000000000 : Boolean);
        VAR
          WshShell@1000000003 : Automation "{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} 1.0:{72C24DD5-D70A-438B-8A42-98424B88AFB8}:'Windows Script Host Object Model'.WshShell";
          Text50000@1000000005 : TextConst 'ENU="""%1"" %2"';
        BEGIN
          {=== How to Work
          cuWshShell.fnWshShellRun('C:\Program Files (x86)\Microsoft Dynamics NAV\60\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe',
          '/?',1,FALSE);
          }
          {===
          object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])
    
          strCommand
            String value indicating the command line you want to run. You must include any parameters you want to pass to the executable file.
    
          intWindowStyle
            Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.
    
          bWaitOnReturn
              Boolean value indicating whether the script should wait for the program to finish executing
            before continuing to the next statement in your script.
            If set to true, script execution halts until the program finishes,
            and Run returns any error code returned by the program.
            If set to false (the default), the Run method returns immediately after
            starting the program, automatically returning 0 (not to be interpreted as an error code).
          }
          {===WindowStyle Enumeration
          0 Hides the window and activates another window.
          1 Activates and displays a window. If the window is minimized or maximized,
            the system restores it to its original size and position. An application
            should specify this flag when displaying the window for the first time.
          2 Activates the window and displays it as a minimized window.
          3 Activates the window and displays it as a maximized window.
          4 Displays a window in its most recent size and position. The active window remains active.
          5 Activates the window and displays it in its current size and position.
          6 Minimizes the specified window and activates the next top-level window in the Z order.
          7 Displays the window as a minimized window. The active window remains active.
          8 Displays the window in its current state. The active window remains active.
          9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size
            and position. An application should specify this flag when restoring a minimized window.
          10 Sets the show-state based on the state of the program that started the application.
          ====}
          CREATE(WshShell,FALSE,ISSERVICETIER);
          WshShell.Run(STRSUBSTNO(Text50000,ptxtCommand,ptxtParameter),pintWindowStyle,pblnWaitOnReturn);
          CLEAR(WshShell);
        END;
    
        BEGIN
        END.
      }
    }
    

    Best Regards,
    Yukon
    Make Simple & Easy
Sign In or Register to comment.