Hi Expert,
Am trying to run net stop && net start for restarting NavInstance but I always encountered error "Access is Denied". Does anyone tried doing this successfully?
Here are my codes:
Process := Process.Process;
Process.StartInfo.UseShellExecute := FALSE;
Process.StartInfo.FileName := 'cmd.exe';
Process.StartInfo.Arguments := '/c NET STOP MicrosoftDynamicsNavServer$InstanceName && NET START MicrosoftDynamicsNavServer$InstanceName';
Process.StartInfo.CreateNoWindow := TRUE;
Process.StartInfo.RedirectStandardError := TRUE;
Process.Start();
ErrMsg := Process.StandardError.ReadToEnd();
IF ErrMsg <> '' THEN
ERROR(ErrMsg)
ELSE BEGIN
Result := Process.StandardOutput.ReadToEnd();
END;
CLEAR(Process);
Is there a way to run this as an admin?
Thank you,
Marc
Answers
I would not suggest to run this out of NAV itself, if it was only because the connection will close anyways when the service tier is restarted.
Thanks for your reply! Am fully aware on that, Reason why I want to do it on NAV is I want to restart the services with a certain condition and have it run on the Job queue. I tried it also to put the command line in the batch file and call it NAV but still getting the same error
The good thing about restarting them regularly, is that you are sure that all events are up and running. In theory this should not be necessary, but that is just theory. Events every now and then "collapse", a restart will fire them up again.
> Windows (server) has an excellent scheduler. My service tiers reboot/restart every night at 4:00 AM.
> The good thing about restarting them regularly, is that you are sure that all events are up and running. In theory this should not be necessary, but that is just theory. Events every now and then "collapse", a restart will fire them up again.
Agreed, but having it run on windows scheduler would means I will lose control on restarting of services, it will just keep restarting and restarting.. What am planning was when NAV finds an over due InProcess in Job queue logs it will marked it as an error then that's the time system will call the restarting of services (This process will run on job queue). Unless I could enable/disable the windows scheduler? That would solve my problem.. 🤔🤔🤔 Maybeeee, that could work let me look into that also. lol!