12-23-2009 08:09 PM
Hi
Everyone
I am using devcon the utlility of microsoft for restart my connection USB of a dispositive (scanner) but I have a big problem, when I run the application devcon with a bat file I have not problem, I can see in the device manager of my computer how the application restart the connection USB with the dispositive but the problem begin when I want to call the file bat with a application development in CVI 7.1. When I execute the application of cvi devcon not work, I don't see any change in the device manager.
I am using the function Launchexecutable of CVI for to call the file .bat that has been configurated for run the devcon utility.
somebody can help me with this problem.
I will appreciated your help
Thanks.
Mario Ku.
12-23-2009 11:54 PM - edited 12-23-2009 11:58 PM
Hi Mario,
It can even be a simple file path typo or missing double backslashes in path string ("c:\\...\\...\\devcon.bat").
Did you check the return value of LaunchExecutable function?
It returns 0 for success and negative values for errors.
There 22 different error conditions documented. It may help.
12-24-2009 02:59 AM - edited 12-24-2009 03:00 AM
How are you using LaunchExecutable to run your batch file? Depending on the commands included in it you may need to prepend to the command string "cmd /c": some informations can be found here and here.
Are you sure the batch file is called? You could edit it to add some echo command redirected to an output file to help you in understanding which part of the batch is executed and which is not.
Additionally, devcon itself returns an errorlevel which may be trapped inside the batch file to give you informations on whether it was successful or not.
12-24-2009 08:53 AM
Hi
To all
Thanks for your fast responces.
Ebalci
I have checked the path in where I am call to file.bat and this has double \\ this is correct I am call to aplication of this form
char c_pathExecutable[50]={"c:\\Utility_Devcon\\i386\\restartUSB_sierra.bat"};
i_status = LaunchExecutableEx(c_pathExecutable, LE_SHOWNORMAL,&LaunchExecutable);
inside of the file .bat I have configurated the call to utiility devcon.exe for restart the dispositive USB.
also I have verify the response of the function LaunchExecutable of CVI and this return me 0 of success but I have the same problem, I dont see that the restart of the dispositive in the device manager.
Robert
I believe that the file .bat is not execute of correct form because in the call to the aplication Devcon.exe I have configurated other file for get the responce of if the devcon was succesful.
I have configurated the file .bat of this form.
devcon restart USB\VID_05* >> devcon_restart.txt.
in devcon_restart.txt I can see if devcon is working well.
if I run the aplication .bat alone devcon work well devcon denerate the file devcon_restart.txt and in this file I get the message "USB\VID_05E0&PID_1200\S/N:2E07A5FF59B29F49AA36559EBACC66E3_REV:PAAABC06-001-R00-: Restarted
1 device(s) restarted.
but when I run the file .bat with the aplication cvi devcon does not generate the file devcon_restart.txt .
Do you have some other idea for fixed the problem??
12-24-2009 12:26 PM
Is it possible to try that on our machines if send us the files?
Does it require any special hardware?
Even so, we may see the txt file being created with an error message in it.
12-24-2009 01:08 PM
Thanks so muchfor your help.
The aplication is running now the problem was with the file .bat, I needed to add the path of the devcon.exe in the configuration of the file .bat see below.
cd C:\Utility_Devcon\i386
devcon restart USB\VID_05* > devcon_restart.txt
I needed to add the first line for that the aplication in cvi work well . the problem was that the aplication run the file .bat but never find the path for can run the devcon.exe
with this linea the file .bat run well.
Regards.