Need help with alternate to SHELL

lombielombie Member Posts: 15
Hi Everyone,

I have created a .Net application that creates a PDF for a MSSQL reporting services report we have created and expects 5 parameters.

I can successfully run it whit the standard Nav SHELL comand as below:

Ret := SHELL(ApplicationString, ReportId, RunMode, FORMAT(inSalesInvoiceRec."Sell-to Customer No."), FORMAT(inSalesInvoiceRec."No."), YearTxt);
Typically this would translate to something like this:
Ret := SHELL('\\someshare\myapp.exe', 'PDFINVOICE', '1', '1234', 'INV123456', '2012');

This works really well except for the untrusted application message. As I need to run this application 100s of times per run from a code unit I need bypass this message.

I have tried to use a 'Microsoft Shell Controls And Automation'.Shell object but I get error message attached. I've read multiple posts on this topic and I'm still hitting my head up against a brick wall. ](*,) ](*,) ](*,)

I have included my code below.

What am I missing???

Cheers
VAR global
     WSHShellObj@1000000001 : Automation "{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} 1.0:{72C24DD5-D70A-438B-8A42-98424B88AFB8}:'Windows Script Host Object Model'.WshShell";
VAR local
      Ret@1100011 : Integer;
      ShellString@1100012 : Text[256];
      WinStyle@1100013 : Variant;

     IF ISCLEAR(WSHShellObj) THEN
         CREATE(WSHShellObj);

      ShellString := ApplicationString + ',' +  ReportId + ',' + RunMode + ',' + FORMAT(inSalesInvoiceRec."Sell-to Customer No.") + ',' +
      FORMAT(inSalesInvoiceRec."No.") + ',' + YearTxt;

      WinStyle := 1;
      WSHShellObj.CurrentDirectory := PDFGenCtrlRec."Console Applcation Folder";
      ret := WSHShellObj.Run(ShellString, WinStyle);
      CLEAR(WSHShellObj);

Comments

  • FDickschatFDickschat Member Posts: 380
    When using WSHShell.Run you should do something like this:
    Result := WshShell.Run("C:\My Folder\MyApp.exe" PutAllParametersHere, WindowStyle, WaitForFinish);
    
    Frank Dickschat
    FD Consulting
  • lombielombie Member Posts: 15
    Thank you Frank that did the trick sort of. This removed the NAV untrusted warning but now I get the Windows untrusted warning (see attached image). To get around this we had to add our file share to a trusted local intranet site in internet explorer.
    =D> \:D/
    VAR global
         WSHShellObj@1000000001 : Automation "{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} 1.0:{72C24DD5-D70A-438B-8A42-98424B88AFB8}:'Windows Script Host Object Model'.WshShell";
    VAR local
          Ret@1100011 : Integer;
          ShellString@1100012 : Text[256];
          WinStyle@1100013 : Variant;
          WaitForFinish@1100014 : Boolean;
    
         IF ISCLEAR(WSHShellObj) THEN
             CREATE(WSHShellObj);
    
          ShellString := ApplicationString + ' ' +  ReportId + ' ' + RunMode + ' ' + FORMAT(inSalesInvoiceRec."Sell-to Customer No.") + ' ' +
          FORMAT(inSalesInvoiceRec."No.") + ' ' + YearTxt;
    
          WinStyle := 1;
          WaitForFinish := TRUE;
          WSHShellObj.CurrentDirectory := PDFGenCtrlRec."Console Applcation Folder";
          ret := WSHShellObj.Run(ShellString, WinStyle, WaitForFinish);
          CLEAR(WSHShellObj);
    
    
Sign In or Register to comment.