Jump to content

LabWindows question


MikaelH

Recommended Posts

Hi Guys

Sorry for using such a bad word as LabWindows here on LAVA, but I have a development team in Fremont and Shanghai that develop all their code in LabWindows. Since you can't do all cool stuff there I had to write the intelligent code in LabVIEW, and have them to call my LV exe file.

I let them control the behaviour to my exe file with arguments so they can call it like this: MES_Finish.exe --PreCure or MES_Finish.exe –PostCure

But the developers say that LabWindows can't call exe files with arguments.

Does anybody know if this is true?

A work around that didn't work either, was for them to call 2 batch files with the argument syntax in.

Cheers,

Mike

Link to comment

Here is a quote from the CVi documentation:

LaunchExecutable

int LaunchExecutable (char filename[]);

Purpose

Starts running a program and returns without waiting for the program to exit.

Note If you want to wait for the program to exit, use the system function in the ANSI C Library.

The program must be an actual executable; that is, you cannot launch commands intrinsic to a command interpreter.

The executable can be either a DOS or Windows executable, including *.exe, *.com, *.bat, and *.pif files.

.exe, .com, and .bat DOS programs use the settings in _default.pif (in the Windows directory) when running. You can change their priority, display options, and so on., by editing _default.pif or by creating another .pif file. Refer to www.msdn.com for information about creating and editing .pif files.

If you need to execute a command built into command.com such as copy, dir, and others, you can call LaunchExecutable with the following command:

command.com /C DosCommand args

where DosCommand is the shell command you want to execute. For example, the following command string copies file.tmp from the temp directory to the tmp directory:

command.com /C copy c:\\temp\\file.tmp c:\\tmp

Note If you want to monitor whether the launched executable has terminated, use LaunchExecutableEx.

In other words: It should work...

  • Like 1
Link to comment

It definitely works. I played around with the different LW API functions. You can even use the system() function that is part of the ANSI C library. My example command was:

char *cmd="cmd /k echo \"Hello world\"";

Here are the options:

// Does not wait for the executable to finish.

LaunchExecutable(cmd);

// Waits for the executable to finish. Even part of the ANSI C standard.

system(cmd);

// Runs the executable...

int procHandle = 0;

LaunchExecutableEx(cmd, LE_SHOWNORMAL, &procHandle);

// .. and enters a loop (timing 0.1s) that waits for the executable to finish.

while(!ExecutableHasTerminated(procHandle))

{

Delay(0.1);

}

There's really no problem here, perhaps there was one years ago in the stone age of programming, I have no clue :-)

And why not, I can create a DLL also...or convince them to migrate to a real programing language ;-)

That may be an even better idea ;-)

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.