Showing results for 
Search instead for 
Did you mean: 

Using System to run devcon

I am running devcon with System The problem is, it works well when I run cmd as an administrator manually and I can read the output,  using "devcon findall =ports" but when I run the same command with labview system , devcon seems to open another cmd window and runs in it and then close quickly resulting in a blank output.I used an indicator to show the result that is "'devcon' is not recognized as an internal or external command,
operable program or batch file."



I have no idea how to run cmd as an administrator by LabVIEW. 

Any advise will be appreciated.

0 Kudos
Message 1 of 10

Did you specify the full path to devcon?  If not, you must have the directory added to your PATH environment variable. 


Run Minimized = TRUE;

Wait Until Completion = TRUE;

LabVIEW 2017
LabVIEW Programming
0 Kudos
Message 2 of 10

devcon is stored in C:\Windows\System32.. It works when I mannually run cmd as administrator. However when I open it with labview, it does not work.


I have attached my vi.Capture.PNG

Message 3 of 10

Don't use cmd.exe as the command line input.  Use your devcon command instead.


My system doesn't have a devcon file in the system32 directory.  If this is a custom application, I would recommend not putting it in system32 folder but rather in a project folder.  There may be Windows rules about running applications located in key system directories that require administrator privileges. 

LabVIEW 2017
LabVIEW Programming
0 Kudos
Message 4 of 10

I have put devcon into the file that contains my labview program. Based on your suggestion, I put "devcon findall =ports" directly into the command line and left working directory blank.Capture.PNGCapture2.PNG

0 Kudos
Message 5 of 10

The post I made here clearly shows all that is needed to run devcon as a command line.  You aren't using the system exec correctly.


But even if you are you are running the command line as an administrator, but are you running LabVIEW as an administrator?  LabVIEW opens a command prompt (sorta) and will inherit the privileges that it was ran with.  As I said there, lowering your UAC if possible run devcon properly.

Message 6 of 10

Hi dude, thank you for your time. Really appreciate.


In you post, I have tried that but it does not work properly for devcon.

0 Kudos
Message 7 of 10


I've tested it on several systems and it seems to work fine.  Here is the image showing me attempting to remove my DVD drive.  You can see it can't actually remove the drive, but the fact that it is trying means it is being called properly.



Message 8 of 10

Hi there,


I know this is a fairly old discussion but I would like to bring it up once more since there has been no clear answer to me yet. Long story to be short, I have tried to use devcon.exe with System in LabVIEW to control some USB devices. After following the following link I am now able to control USB devices when running devcon through the Windows command line (with admin account though).

However, I could not make that work the same way with System in LabVIEW. Each time I tried to run a devcon command I get the error message like "'devcon.exe' is not recognized as an internal or external command,
operable program or batch file."


So I am wondering if there is a solution to that issue.



0 Kudos
Message 9 of 10



As you mentioned, this is a really old thread. I would recommend starting a new thread with this question because it will get more exposure and traffic on it. Also, when you make a new post, sharing your code might be helpful to those looking at your issue.


Just a thought: try running LabVIEW as an administrator to see if that changes anything?

0 Kudos
Message 10 of 10