LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How could I have a VI execute a DOS batch file?

I need to update the PC's hardware timeclock and the Windows clock via a VI front panel. If I can update hardware and windows timeclocks from a DOS prompt (TIME/NEW TIME), is there a way to provide a LV interface for the same operation? If a VI could run a DOS batch file, having the operator enter a new time in a DOS prompt window is the next best thing.

Thanks,

Jeff Bledsoe
Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 1 of 7
(3,579 Views)
Use System Exec on the Communication palette to either run a batch file or run the DOS Time command directly.
Message 2 of 7
(3,577 Views)


@Dennis Knutson wrote:
Use System Exec on the Communication palette to either run a batch file or run the DOS Time command directly.




Thanks. I found an example called ping.vi on the NI website. Wondering where to find the syntax for the command line in System Exec.vi. In the example, the command line starts begins: command.com C/ .

Jeff
Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 3 of 7
(3,570 Views)
The syntax is that of the operating system.
Have you tried right clicking the VI and selecting Help?

___________________
Try to take over the world!
Message 4 of 7
(3,564 Views)


@tst wrote:
The syntax is that of the operating system.
Have you tried right clicking the VI and selecting Help?




I found the online example by selecting help. I'm using LV 5.1 and I've noticed that offline help is not as detailed as it is with LV 7 Student Edition (I have student edition at home).

In my latest attempts, I have the string "command.com /c time" wired to the command line input of system exec.vi. I get the dos prompt and a request for a new time.

To avoid the operator having to enter the time in the DOS window, I tried passing carriage returns and a time update value in the command line input. It didn't work. Do I have to add a system exec.vi for each command line entry and concatenate the vi's somehow?

Thanks,

Jeff
Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 5 of 7
(3,546 Views)
In the Good Old Times of DOS I used to write command input in a file and use the input redirection characters.
Try
command.com /c time < mytime.txt,
where mytime.txt must contain the new time settings.

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 6 of 7
(3,540 Views)


@pincpanter wrote:
In the Good Old Times of DOS I used to write command input in a file and use the input redirection characters.
Try
command.com /c time < mytime.txt,
where mytime.txt must contain the new time settings.

Paolo




It worked! I added a carriage return after the text string so the DOS prompt closes out. It's a simple matter to build an operator interface that writes a string to a text file. Thank you very much.

Jeff
Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 7 of 7
(3,524 Views)