LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System exec displays an error popup

Solved!
Go to solution

Hi community,

 

in certain cases I need to shut down and restart outlook. In order to do so I a batch file what I want to get rid of and do everything from LabVIEW. When I run the following snippet I receive an error popup complaining that the path is not valid. Which is true because on some computers outlook is in the program files folder, in some computer it is in the program files(x86) folder, but that should not be a problem because of the "IF EXIST". It works fine from the batch file.

 

Please help me out here.

 

Thanks!

 

ps: I know this is not the right way. I would like to use activeX but I have not found any way to actually start outlook. (I need to have it open, not just sending a mail with activeX)

 

system_exec.png

 

 

 

 

0 Kudos
Message 1 of 7
(2,516 Views)

Hi 1984,

 

I usually create a small batch file for such tasks: this way you could combine the "IF EXISTS" into a more complex IF-THEN-ELSE structure…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(2,507 Views)

Yes... I can do that very easily. But I would rather keep this function in the code itself.

0 Kudos
Message 3 of 7
(2,503 Views)

- create the batch file as string constant.

- save the string to a temporary file

- SystemExec the temporary batch file

- delete the temporary batch file

All within your code… 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(2,495 Views)

No its not. That requires a file to get saved to the hdd.

0 Kudos
Message 5 of 7
(2,485 Views)
Solution
Accepted by topic author 1984

My outlook.exe is in C:\Program Files (x86)\Microsoft Office\Office14.  I got the error you mentioned when I ran your snippet (corrected for office 12/14), but got no error when I removed the third element from your array.  It seems that %programfiles% is clever enough to get the program from (x86).  I do have a C:\Program Files\Microsoft Office\Office14 folder, but there's no outlook.exe in it.

 

Example_VI_BD.png

 

I found this on Stack Overflow

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 6 of 7
(2,476 Views)

<facepalm>

 

thanks Jim! Work like a charm.

0 Kudos
Message 7 of 7
(2,445 Views)