Jump to content

System Exec.vi to execute 'goto' command


Recommended Posts

Hi friends,:thumbup1:

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.:frusty:mY2.vi

Please help..!!! attached is my vi.

Thanks for your time...!!! :worshippy:

sharon

P.S

The following VI(mY1.vi) with multiple dos commnads is okie...mY1.vi

Edited by Sharon_
Link to comment

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.

Link to comment

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? :lightbulb:

Thanks for your time..!!! :yes:

Sharon

Link to comment

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? :lightbulb:

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.

Link to comment
  • 5 weeks later...

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

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.