"Shelling out" problem

ccbryan63ccbryan63 Member Posts: 115
edited 2010-11-06 in NAV Three Tier
Hello gentlefolk,

I am having trouble getting the Role Tailored client to run an outside program. Here is the error I am getting:

"This message is for C/AL programmers. The call to member Run failed: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)."

The RTC is set up with the client on the workstation and the other two tiers on a single server. Here is the code in question. A couple of things to note: first, this same code runs without a hitch on the Classic side in NAV 2009. Secondly, if I point Docfile to a bogus path, I get the "EXE not found" confirm window.
   DocFile := 'F:\Old Storage Drive\Payroll_import\Payroll_Import.exe';
   DocComp := ' "'+CONVERTSTR(COMPANYNAME,'.','_')+'"';

   IF FILE.EXISTS(docfile) THEN
      BEGIN
        IF ISCLEAR(wShExec) THEN CREATE(wShExec,FALSE,TRUE);
        WshMode := 0;
        WaitForEndOfCommand := FALSE;
         ReturnCode := wShExec.Run(docfile +
                         DocComp,WshMode,WaitForEndOfCommand);
        END ELSE
           IF CONFIRM('EXE Not FOUND!') THEN  CurrPage.UPDATE(FALSE);
    END;

So it's a NAV error saying it can't find the file, but I know it CAN find the file because if I point it elsewhere it gives me the confirm window. I confess I am puzzled. Any ideas? Thanks in advance...

Comments

  • BeliasBelias Member Posts: 2,998
    i don't think that your combination of your docfile + doccomp will find an existing file...
    based on your code, it would be
    F:\Old Storage Drive\Payroll_import\Payroll_Import.exe"mycompanyname"
    and such a file can't exist...
    i think your code is not correct, here
    ReturnCode := wShExec.Run(??docfile + DocComp??,WshMode,WaitForEndOfCommand);
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ccbryan63ccbryan63 Member Posts: 115
    Thanks Belias, I'll investigate that right away. But... the code as written works fine in NAV 2009 Classic... is there a difference in the way RTC passes instructions to the shell?
  • ccbryan63ccbryan63 Member Posts: 115
    I changed the code slightly so I could be certain of what the RUN command was working with:
       docfile := 'F:\Payroll_import\Payroll_Import.exe';
       docComp := ' "'+CONVERTSTR(COMPANYNAME,'.','_')+'"';  //THIS ONE WORKS WITH SHELL()
       cmdString := docfile + docComp;
      
      IF FILE.EXISTS(docfile) THEN
          BEGIN
            IF ISCLEAR(wShExec) THEN
            CREATE(wShExec,FALSE,ISSERVICETIER);
            WshMode := 0;
            WaitForEndOfCommand := FALSE;
            ReturnCode := wShExec.Run(cmdString,WshMode,WaitForEndOfCommand);
    

    At the point of the Run, Nav debugger shows the value of cmdstring as "F:\Payroll_import\Payroll_Import.exe "Company Name, Inc_""

    If I go to Start/Run and enter F:\Payroll_import\Payroll_Import.exe "Company Name, Inc." it works perfectly. "Company Name, Inc_" is correctly passed as a parameter. If I run this same code in NAV Classic it works just fine. The problem insn't in the syntax, unless RTC requires a different syntax. That's what I don't know... does anyone?

    Thanks...
  • BeliasBelias Member Posts: 2,998
    oh, companyname is a parameter of the exe #-o
    where's the exe file? i think on the client machine. if so, the service tier cannot read it. you have to put the exe file in a place accessible from service tier. (and with the correct path).
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ccbryan63ccbryan63 Member Posts: 115
    That might be the problem... the path difference from the service tier. That gets immensely confusing, the whole 'where's the file?" thing. At this client it's crazy. For instance, on the server, the directory where the executable lives is "F:\Old Storage Drive\Payroll_Import\" but the client workstations are mapped directly to Old Storage Drive so for them the path is "F:\Payroll_Import". So I'm forever switching the path back and forth whenever I develop or deploy. But the service tier lives on the server, so maybe I need to go back to the 'Old Storage Drive' path... but of course that won't work for the Classic client. Sheesh.

    Thanks man!
  • BeliasBelias Member Posts: 2,998
    ccbryan63 wrote:
    That might be the problem... the path difference from the service tier. That gets immensely confusing, the whole 'where's the file?" thing. At this client it's crazy. For instance, on the server, the directory where the executable lives is "F:\Old Storage Drive\Payroll_Import\" but the client workstations are mapped directly to Old Storage Drive so for them the path is "F:\Payroll_Import". So I'm forever switching the path back and forth whenever I develop or deploy. But the service tier lives on the server, so maybe I need to go back to the 'Old Storage Drive' path... but of course that won't work for the Classic client. Sheesh.

    Thanks man!
    use ISSSERVICETIER to differentiate the behavior of the program between the 3 tier client and the classic client
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.