To download NI software, including the products shown below, visit ni.com/downloads.
This example shows how .NET can be used to start and stop Windows Services programmatically without having to use System Exec commands.
System Exec does not allow for the command prompt to be ran as an administrator. To get around this, an application and installer must be created or LabVIEW itself has to be ran as an administrator. This example provides a workaround to control Services using .NET. The benefit is that it can elevate the permissions for the application to gain access to certain Services without having to build an executable or having to run LabVIEW as an administrator as you would with System Exec. It uses runas and net commands to configure the process through .NET. The default configuration is set to turn on/off Windows Themes. This was inspired from lavag.org.
Note: Disabling some Services can cause unexpected system behavior. Research any Services prior to running this VI.
Steps to Implement or Execute Code
Additional Information or References
**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.
This. Was. Perfect. Timing.
I see that this was posted on Jan. 3 and the last task I started on Jan. 3 was a System Exec call to stop a service. I started the struggle and search this morning and ran across this little snippet just before lunch. Thanks for saving me any further headache and head scratching!
Thank you. Also found this example very useful. Is there a way to check if the service is running the same way in this code?