Is is possible stopping the NAS service after running NASHandler function in codeunit 1??

Hi all,

Currently I can suceessfully execute the specific codeunit instance calling from HASHandler when NAS service was started.

I just wonder if it is possible that writes codes to the codunit 1 to stop the NAS service after running the codeunit instance in the NASHandler.

I saw a message that shows in the ms-dos screen after the the specific codunit instance was execute successfully from the NAS service. The message is “Press ESC to shut down the Navision Application Server”. That will be perfect if the NAS can be stoped automatically after execute the specific codeunit object!!

Appreciate it if you can help me out. [:)]

Hello.

You can run shell command with command “net stop NASServiceName”

This will stop the service name. You can also use windows scripting automation to execute the command.

Hi Rashed,

The problem is the when I use the same script that register as a windows service, it doesn’t work. If I use the same script to execute the NAS server in command line, it works perfectly but can’t be stoped until I manually press “ESC” key.

The script is below:

“C:\Program Files\Microsoft Business Solutions-Navision\Application Server\nas.exe” appservername=NASCRONUS_1, servername=, database=C:\Program Files\Microsoft Business Solutions-Navision\Client\database.fdb, company=CRONUS International Ltd., nettype=,startupparameter=InvAgeRpt

You need to use windows script host Automation.

txtCommand := ‘C:\Program Files\Microsoft Business Solutions-Navision\Application Server\nas.exe" appservername=NASCRONUS_1, servername=, database=C:\Program Files\Microsoft Business Solutions-Navision\Client\database.fdb, company=CRONUS International Ltd., nettype=,startupparameter=InvAgeRpt’

WSHExec := WindowShell.Exec(txtCommand);
WSHTextStream := WSHExec.StdOut;

CLEAR(EXITNAS);
StartDateTime := CURRENTDATETIME;
StandardError := FALSE;
CLEAR(ALLResponseLines);
I := 1;
WHILE (NOT WSHTextStream.AtEndOfStream) AND (NOT EXITNAS) DO BEGIN

IF STRPOS(Responseline,‘ESC’ ) <> 0 THEN BEGIN
EXITNAS := TRUE;
END;

End;

WSHTextStream.Close;

SLEEP(2000);
WSHExec.Terminate;

Name DataType Subtype Length
WindowShell Automation ‘Windows Script Host Object Model’.WshShell
WSHExec Automation ‘Windows Script Host Object Model’.WshExec
WSHTextStream Automation ‘Windows Script Host Object Model’.TextStream
txtCommand Text 1000

Hi Rashed,

Thanks for the detail explanation. Is it correct that I need to run a Navision client and execute a codue unit object include the script code?

The prupose that I want to use NAS to execute codeunit object is to do the job scheduling automation without open any Navision client. I am not sure if the way can fit the requirement.

In order to run business logic in Navision, you need to run NAS or Navision client. Next version of Navision 2009 will have webservices, and then you can call webservices.

Are you using 2 NAS services?

1 to call the codeunit. Then in the codeunit you are calling the executable.

Munib

Maybe you should look into the SC.EXE feature of the “Windows Resource Kit” (you could use sc.exe on any machine), maybe this could help!

http://technet2.microsoft.com/windowsserver/en/library/0a658e97-51d5-4109-b461-a474c799964e1033.mspx?mfr=true

Regards,

Jörg