LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Running and EXE file and storing the return data

I have an exe file that converts a MAC address to a key when run through the cmd prompt.
 
example :  If I type mac2key.exe 00:13:0a:00:01:05  in the cmd prompt 00:13:0a:00:01:05, "715a02" is returned
 
C:\>mac2key.exe 00:13:0a:00:01:05
00:13:0a:00:01:05, "715a02"
 
I would like to launch the exe with a MAC address attached and be able to capture the return string.  How can I perform this task in CVI?
 
0 Kudos
Message 1 of 7
(3,970 Views)

if mac2key is an executable that you just want to run and not modify, you can do the following:

system("mac2key.exe 00:13:0a:00:01:05 > output.txt");

The > sign rediects the programs output to a file.  You specify the filename (example output.txt) and path to be whatever you want. You can then read that file (fopen(), fscanf(), etc.) to get the key in your CVI program.

Message 2 of 7
(3,962 Views)
Typing too slow again - Al beat me to itSmiley Very Happy

Message Edited by jr_2005 on 05-09-2007 02:02 PM

0 Kudos
Message 3 of 7
(3,965 Views)

I ran the code and it creates a blank text file.  Help!!!

 

0 Kudos
Message 4 of 7
(3,920 Views)

I also pasted the code in the command line and it works fine but it does not work when I run it from CVI.  The mac2key.exe file and the txt file are in the C: directory.

 system("C:\\mac2key.exe 00:13:0a:00:01:05 > c:\\output.txt");

 

 

0 Kudos
Message 5 of 7
(3,918 Views)
Try this:

    system("cmd /c C:\\mac2key.exe 00:13:0a:00:01:05 > c:\\output.txt");

JR
Message 6 of 7
(3,915 Views)

That did the Trick!

 

Thank You!

 

Jon K.

 

0 Kudos
Message 7 of 7
(3,899 Views)