There are several ways to achieve a unique thread that can be elevated. Placing code in a unique thread would allow the ability to spawn code, elevate, perform action and then de-spawn code and thread.
- Timed structures spawn a unique thread per structure.
- The only single thread execution system is the UI thread. If your elevated VIs were all ran in the UI execution system, you could have one thread run all the code.
- This is not recommended, as this has the issue of running code in the UI thread, where various events are also ran in this thread and can pause execution if not handled correctly.
- You can run "subroutine" VIs, where all the code in that VI would run in a single thread.
- This comes with a caveat that Asynchronous operations aren't allowed in subroutines. This will depend on why your application needs elevation.
After creating a unique thread, you can use Operating System functions to give the thread elevated access. For Windows, this can be performed using the Win32 API
LogonUserA function to log in as a user with elevated privileges.