Example Code

Shut Down Computer VI (Windows XP and later) Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI will shut down the computer, closing LabVIEW a few seconds before.

 

Description

There are certain times you may want LabVIEW to shut down your computer, for example when the PC or Touch Panel you are using is solely dedicated to one application. In this case, you could set the application to run at startup and use the following VIs to shut down. I have included two VIs. One uses an event structure (preferable if you have LabVIEW Full, Professional, or do not need to modify the Event Structure). This VI is "Shutdown_Computer_Events.vi". This VI is also more modular because you can wire any amount of time to wait and give the user a chance to abort.I have also attached a VI which does not use an Event Structure ("shutdown_computer.vi"). The disadvantage is that you must hard-code a time before shutdown and a time to wait (I used 10 and 8 seconds, meaning you have 8 seconds to click the Abort button in the dialog before LabVIEW shuts down).

I have also attached a VI which does not use an Event Structure ("shutdown_computer.vi"). The disadvantage is that you must hard-code a time before shutdown and a time to wait (I used 10 and 8 seconds, meaning you have 8 seconds to click the Abort button in the dialog before LabVIEW shuts down).

 

Requirements

Software:

  • LabVIEW 2012 (or compatible)

Steps to Implement or Execute Code

1. Run the VI.
2. Push convenient button to shutdown computer or aborting shut down process. 

 

Additional Information or Resources

Shut down with Event StructureShut down with Event StructureShut Down without Event StructureShut Down without Event Structure

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

With warm regards,

David D.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.