Not using only Navision. There are a couple different applikations that will terminate programs in windows. So you could have Navision write to a file if an error occurs, and then have the applikation read the file and terminate navision
if you go to the database session form in Navision 4.0 you can press the F4 - Delete and close a session, if you can do it there manually you should be able to do it pragmatically. But I am just an end user without developer license so I can not help any more.
My guess is you would need to add to your code, a search for your session, and a delete comand.
Sending Alt+F4 is not a complete solution as the window asking for saving ZUP file can appear and hold Navision client running. So you'll have to send it twice . It will be better if you will send a ' taskkill' command or run a custom application which will terminate Navision client process.
Comments
can you please give the name of some of such application?
My guess is you would need to add to your code, a search for your session, and a delete comand.
just a guess though.
WshShell Automation 'Windows Script Host Object Model'.WshShell
if returnvalue<>0 then begin
CREATE(WshShell);
WshShell.SendKeys('%{F4}'); //Alt+F4
end;
Best regards.