Sharon_ Posted August 5, 2010 Report Share Posted August 5, 2010 (edited) Hi friends, I am trying to execute batch file commands in Labview thru' System Exec.vi.. I could run the commands if there is no 'jumping'. I wrote the following script to hide some folders on a machine, if the computer name matches to some value. @echo off IF %COMPUTERNAME% ==MyMachine goto MyMch ELSE attrib C:\KK -s -h exit :MyMch attrib C:\KK +s +h exit If I run the above as a .bat file everything is fine. But the same code added in my Vi but it is not working.mY2.vi Please help..!!! attached is my vi. Thanks for your time...!!! sharon P.S The following VI(mY1.vi) with multiple dos commnads is okie...mY1.vi Edited August 5, 2010 by Sharon_ Quote Link to comment
ned Posted August 5, 2010 Report Share Posted August 5, 2010 Make a batch file and call it from your LabVIEW code. There's no way this will work; have you tried doing the same thing by opening a command line and pasting in the exact same line that you're calling from LabVIEW? With a batch file, the interpreter gets a chance to parse the entire file and find the destination of the jump. When you enter it all on one line like that, the interpreter handles each line one at a time. It sees the goto command but it hasn't yet seen the target of the goto so it fails. Quote Link to comment
Sharon_ Posted August 6, 2010 Author Report Share Posted August 6, 2010 Make a batch file and call it from your LabVIEW code. There's no way this will work; have you tried doing the same thing by opening a command line and pasting in the exact same line that you're calling from LabVIEW? With a batch file, the interpreter gets a chance to parse the entire file and find the destination of the jump. When you enter it all on one line like that, the interpreter handles each line one at a time. It sees the goto command but it hasn't yet seen the target of the goto so it fails. Hi Ned, The same Vi will be run in several machines. Is it possible to 'add' my batch file in the VI in stead of calling it from a location? Thanks for your time..!!! Sharon Quote Link to comment
ned Posted August 6, 2010 Report Share Posted August 6, 2010 The same Vi will be run in several machines. Is it possible to 'add' my batch file in the VI in stead of calling it from a location? You could include the batch file in your project (a LabVIEW project can include any type of file, even if LabVIEW didn't create it) and then include it in your build. Alternatively, you could have your VI write the batch file and then run it, since a batch file is just a text file with a .bat extension. Quote Link to comment
Yamaeda Posted September 6, 2010 Report Share Posted September 6, 2010 System Exec, as mentioned, can only perform 1 command (a batch file is 1 command), but you're only really performing 1 command. You perform 1 attrib command depending on machine name. I'd recommend checking the name and parameters in LV and just send 1 system exec as needed (unless LV advanced file functions can change the attributes, haven't checked that). Then no batch file is needed. /Y Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.