How do I save the return value that the CMD should deliver in NAV?

MaximilianN
Member Posts: 4
Hello everybody,
I have the following problem:
I want to use the CMD from NAV to execute the SET HOMDRIVE function. The return value, i.e. the path, should be stored as a variable in NAV.
This is the code:
HomeDriveL := WshShell.Run('SET HOMEDRIVE');
HomeDriveL is a local variable and is from DataType a Text.
But when executing in NAV I get this error:
Error when calling System.__ComObject.Run with the following message: The system cannot find the specified file. (Exception of HRESULT: 0x80070002)
Can someone help me with that?
Many thanks in advance!
I have the following problem:
I want to use the CMD from NAV to execute the SET HOMDRIVE function. The return value, i.e. the path, should be stored as a variable in NAV.
This is the code:
HomeDriveL := WshShell.Run('SET HOMEDRIVE');
HomeDriveL is a local variable and is from DataType a Text.
But when executing in NAV I get this error:
Error when calling System.__ComObject.Run with the following message: The system cannot find the specified file. (Exception of HRESULT: 0x80070002)
Can someone help me with that?
Many thanks in advance!
0
Answers
-
Hello @MaximilianN,
How you are using an Automation variable i gess that you have a 2009R2 NAV version or even lower, so you can try this:HomeDriveL := ENVIRON('HOMEDRIVE');
Regards0 -
Hey @ftornero,
thanks for your answer. When I use this function, there comes an error message, that this function is an outdated method.
Do you know whether there is a new one?
Thank you in advance,
Maxi0 -
0
-
0
-
Hello @MaximilianN,
You can use a DotNet variable to do thatVar Name DataType Subtype Length No EnvVar Text
0 -
Hello @MaximilianN,
Sorry this oneName DataType Subtype Length GetEnv DotNet System.Environment.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
And use like this:HomeDriveL := GetEnv.GetEnvironmentVariable('HOMEDRIVE');
0 -
Hello @MaximilianN,
Another thing is that the DotNet variable must be run on client, otherwise it get you the environment var in the server,
So in the variable properties you must change the value like in the image:
Regards
0 -
@ftornero
Thank you for your help.
Now it works.
Ive made it with the DotNet variable and the property RunOnClient.
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