LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using System exec.vi to run devcon

I am running devcon with System exec.vi. 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 exec.vi , 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
(5,940 Views)

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;

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 10
(5,902 Views)

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
(5,895 Views)

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. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 10
(5,888 Views)

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
(5,884 Views)

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.

 

 

http://forums.ni.com/t5/LabVIEW/How-do-I-reset-a-USB-drive-in-a-VI/m-p/3366146#M990865

 

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
(5,878 Views)

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
(5,870 Views)

What...does...not...work?

 

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.

 

Untitled.png

Message 8 of 10
(5,836 Views)

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 Exec.vi 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).

https://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/i-downloaded-devcon-on-my-win-7...

However, I could not make that work the same way with System Exec.vi 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.

 

Thanks.

0 Kudos
Message 9 of 10
(4,748 Views)

Hello,

 

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
(4,725 Views)