Run CMD Function In NAV 2016

Isaland
Member Posts: 52
Need to develop CMD opertation net use to map network drive from NAV 2016.
Trying to use DotNet variable:
MappingCMDString:
The code:
But nothing being processed. Where i did mistake?
Trying to use DotNet variable:
- System.Diagnostics.Process.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
- System.Diagnostics.ProcessStartInfo.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
MappingCMDString:
net use %1 %2 /user %3 %4 /persistent:yes
The code:
SystemDiagnosticsProcessStartInfo := SystemDiagnosticsProcessStartInfo.ProcessStartInfo('cmd','/c"' + STRSUBSTNO(MappingCMDString,DriveLetter,Path,UserName,Password) + '"'); SystemDiagnosticsProcessStartInfo.RedirectStandardError := TRUE; SystemDiagnosticsProcessStartInfo.RedirectStandardOutput := TRUE; SystemDiagnosticsProcessStartInfo.UseShellExecute := FALSE; SystemDiagnosticsProcessStartInfo.CreateNoWindow := TRUE; SystemDiagnosticsProcess := SystemDiagnosticsProcess.Start(SystemDiagnosticsProcessStartInfo); CLEAR(SystemDiagnosticsProcess);
But nothing being processed. Where i did mistake?

MB7-840
0
Best Answer
-
The problem was in CMD string. I have wrong syntax.
MB7-8405
Answers
-
Try to use RunOnClient = Yes on your DotNet Variables to actually see if something happens - if you haven't done that already.Austrian NAV/BC Dev1
-
Have tried - the same situation. Nothing happened.
Check this command via "Win + R" - it works.
So problem is in calling this line from NAV.MB7-8400 -
The problem was in CMD string. I have wrong syntax.
MB7-8405 -
Hi Isaland,
I tried your code in the 1st post, but also could not get it to work. You mentioned in your last post, it was due to a wrong syntax. What was wrong with the syntax?
Jordi0 -
Hi,
I found out what's wrong. for other ppl looking to this, the correct code is -->SystemDiagnosticsProcessStartInfo := SystemDiagnosticsProcessStartInfo.ProcessStartInfo('cmd','/c ' + STRSUBSTNO(MappingCMDString,DriveLetter,Path,UserName,Password)); SystemDiagnosticsProcessStartInfo.RedirectStandardError := TRUE; SystemDiagnosticsProcessStartInfo.RedirectStandardOutput := TRUE; SystemDiagnosticsProcessStartInfo.UseShellExecute := FALSE; SystemDiagnosticsProcessStartInfo.CreateNoWindow := TRUE; SystemDiagnosticsProcess := SystemDiagnosticsProcess.Start(SystemDiagnosticsProcessStartInfo); CLEAR(SystemDiagnosticsProcess);
Changes are in line 1 of the code. Removed double quotes and added a <space> after /c
Jordi0
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