Running NAS with a scheduler

charlpcharlp Member Posts: 21
edited 2006-03-23 in Navision Attain
Hi all,

I've spent the last two days reading most of the posts with regards to NAS but can't find the answer I'm looking for.

I'm running NAV 3.6 server with application server installed. Everything works fine, and I have even managed to create new services and run them with diffirent parameters.

My problem is that I have specific tasks which I want to run at scheduled times, but I don't want to use a timer to do this. Our license doesn't have the Job Scheduler granules, so that's not an option. I would basically like to start NAS from the command line, and once it finishes with it's task, I would like it to stop executing. Is this possible?

I tried writing a console app in .NET, and passing character code 27 (ESC) to the NAS console window (when started from the command line), in response to the "Press ESC to shut down Navision Attain Application Server NAV-CLASSIC." message, but this doesn't work either.

I can start and stop the service without any problems, but then I've got no idea if the execution of the task completed.

Thanks,
Charl

Comments

  • krikikriki Member, Moderator Posts: 9,112
    Try this:
    In codeunit 1 trigger 99, run another codeunit (NOT singleinstance) to do the work. When this is finished, put this at the end of the codeunit:
    COMMIT;
    ERROR('');
    
    This will commit all changes and then generate an error. This should make the NAS crash and exit. And who cares if he crashed, because his job is done.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • amunozsuamunozsu Member Posts: 30
    You can do this at the end of the task the NAS executes:


    SHELL(TXTCOMANDO, TXTPARAMETRO);

    Where TXTCOMANDO = "c:\windows\system32\Command.com" and TXTPARAMETRO = "/c Net stop NASNAME"

    -- Alejandro --
  • charlpcharlp Member Posts: 21
    Thanks guys!

    kriki - unfortunately NAS terminates prematurely if the ERROR command is in CodeUnit 1 Trigger 99

    amunozsu - your method works like a charm.....but leaves the console window open, which has to be killed with the task manager. But this is easy to fix.

    Cheers!
    Charl
Sign In or Register to comment.