How to Restart NAS through CodeUnit

ckndr47
Member Posts: 100
Hi everybody,
Just wanted to know; is there any way to restart NAS service from codeunit. If yes then please guide me up;
i have another query as well; i am reading an XML message from MSMQ through NAS and then i m writing tht XML to a file; suddenly due to any error the process gets terminated and file gets locked; now the next time when i would run that file it gives me that LOCKING error. I dont know whts the work around of tht issue.
Thanks in Advance,
Regards
Just wanted to know; is there any way to restart NAS service from codeunit. If yes then please guide me up;
i have another query as well; i am reading an XML message from MSMQ through NAS and then i m writing tht XML to a file; suddenly due to any error the process gets terminated and file gets locked; now the next time when i would run that file it gives me that LOCKING error. I dont know whts the work around of tht issue.
Thanks in Advance,
Regards
0
Comments
-
-run "net stop yournasservice" and then "net start yournasservice".
-or you can use pskill (www.sysinternals.com) to kill the nas. And if you put in the services properties that the service must be restarted if killed, it will restart automatically after the kill.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks Kirki,
I know how to restart service from Windows run, but i want to restart that service from Navision Codeunit, i hope you getting me.
Thanks in Advance,
Regards0 -
Try with:
SHELL(TXTCOMANDO, TXTPARAMETRO);
Where TXTCOMANDO = "%systemroot%\system32\Command.com" and TXTPARAMETRO = "/c Net start NASNAME" or "/c Net stop NASNAME"
-- Alejandro --0 -
Check also this link for the doscommand:
http://www.mibuso.com/forum/viewtopic.php?t=12417Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks amunozsu and kriki. Its working now.0
-
Hi,
I used this code to re-start NAS automatically. But I was getting the message "For security reason you are not allow to run following executabels in the shell function when it is passed as a variable".
I am not sure if I have to do or write some other code to run this command.
Please suggest.
Regards
Mini0 -
Sorry, but the "Net Start" / "Net Stop" Command works only, on the same machine.
So a little tip&trick:
If your NAS is on a other machine and you need to stop him from a other machine which runs the Codeunit, like a Client, you can use the psservice.exe. Also if the nas is on the same machine i use psservice to query the state ...
So, with following little code you can start / stop / ask for state a service...... //01 SysTools Garak +++++++ .... GlobServiceName := ServiceName; Command := PSToolPath + '\\' + DNSNameOfServerWhereServiceRun + ' start ' + ServiceName; //start, stop, query ServiceStatus := ExecPSTool(); //here you can create a loop if the Service will be stopped, so you ask, for example 10times the state. If the Service isn't stoped after 10 minutes you can send an error to abort .. //01 SysTools Garak ------- //01 SysTools Garak +++++++ ExecPSTool() : Text[30] GetService := FALSE; IF ISCLEAR(WshShell) THEN CREATE(WshShell); WshExec := WshShell.Exec(Command); WSHTextStream := WshExec.StdOut; i := 0; CLEAR(State); WHILE NOT WSHTextStream.AtEndOfStream DO BEGIN i := WSHTextStream.Line; Line := WSHTextStream.ReadLine(); IF (STRPOS(Line,'SERVICE_NAME: ') <> 0) THEN BEGIN LServName := COPYSTR(Line,STRPOS(Line,':') + 2,STRLEN(Line) - STRPOS(Line,':') + 2); GetService := LServName = GlobServiceName; END; IF GetService THEN BEGIN IF (STRPOS(Line,'STATE') <> 0) THEN BEGIN State := COPYSTR(Line,STRPOS(Line,':') + 5,STRLEN(Line) - STRPOS(Line,':') + 4); END; END; END; CLEAR(WshShell); EXIT(State); //01 SysTools Garak -------
RegardsDo you make it right, it works too!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