Run cmd line as admin

manthonylugo
Member Posts: 46
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
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
0
Answers
-
I created a *.bat file on the application server (where the service tiers are running).
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.IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;0 -
Hi Edo,
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
0 -
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.IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;0 -
> @edoderoo said:
> 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!0 -
when you want to kill a certain process, you can look for the session in the session table (somewhere over 2.000.000.000 as table number) and delete the corresponding record there.IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions