02-21-2011 01:57 AM
Which environment is seen by an executable, which is started by LaunchexecutableEx() in an Labwindows/CVI code module using the Labwindows Adapter in Teststand ? An is is possible to modify that environment ?
We've noticed that a executable, that creates directories for logging files and configuration data in its installation directory, when started standalone, now creates these directories somewhere under C:\Dokumente und Einstellungen\All Users\Dokumente\National Instruments\TestStand 4.2.1\ when started from the CVI code module.
Solved! Go to Solution.
02-21-2011 11:19 AM
The executable you are using is probably adding things based on the current working directory. This is not a best practice. If you own the source code to the executeable you should consider changing it to use GetModuleFileName ( http://msdn.microsoft.com/en-us/library/ms683197%28v=vs.85%29.aspx ) passing NULL for the module handle to get the path where the executeable file is located and use that path rather than the current working directory. I'd argue that using the current working directory is almost never the correct thing for a program to do.
That said, if don't own the code for the executable and just need to get it working, you can use the Windows SDK function CreateProcess ( http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx ) instead which will let you specify a currentdirectory (I don't think the environment is the issue in your case, I think it is the current directory). Or you can use the TestStand call executable step type instead which has a setting for the current directory (I think it calls it the Working Directory).
Hope this helps,
-Doug