To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This program will either Sleep, Shutdown, Lock or Restart your Windows PC in a specified amount of time. This VI uses the producer/consumer design pattern with events and the System Exec V or Call Library Function Node to either sleep, shutdown, restart or lock your PC.
Description
This simple event driven VI uses the System Exec VI or Call Library Function Node to either sleep, shutdown, restart or lock a windows PC.
Call the "LockWorkstation" method within the "user32.dll" using a "Call Library Function Node"
Call the "SetSuspendState" method within the "powrprof.dll" using a "Call Library Function Node". Needs parameters 0,1,0.
It is an extension to my previous community example: Sleep, Shutdown, Restart and Lock Windows programmatically
It was designed so you can change the command as the program is counting down. So you can change the command after it has started counting down. This gives that the consumer loop will constantly poll the notifier using Get Notifier Status Function.
Requirements
Steps to Implement or Execute Code
Additional Information or References
Front Panel
VI Snippet
Tested on windows 7 and written in LabVIEW 2011 with silver buttons. I have uploaded 4 versions. Some have the shutdown, restart, sleep and lock code disabled. It has been replaced using a disable diagram structure and a One Button Dialog Function for testing purposes.
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.