1.

Solve : I can get my batch file to run when I run the batch file using devcon.exe?

Answer»

But, When I use C# to run a form and try running file below it doesn't work. Even though I have devcon.exe in the same folder as the batch file. If I run it by itself it works.

Unload_USB.bat CODE below

ECHO OFF
:: Check Windows VERSION
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
IF     "%OS%"=="Windows_NT" SETLOCAL
VER | FIND "Windows NT" >NUL && GOTO Syntax

:: Check command line arguments -- none required
IF NOT "%~1"=="" GOTO Syntax

:: Check if DEVCON.EXE is available and if not, prompt for download
SET DevconAvailable=
SET Download=
DEVCON.EXE /? >NUL 2>&1
IF ERRORLEVEL 1 (
   SET DevconAvailable=No
   ECHO This batch file requires Microsoft's DEVCON untility.
   SET /P Download=Do you want to download it now? [y/N]
)

:: Start download if requested
IF /I "%Download%"=="Y" (
   START "DevCon" "http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272"
   ECHO.
   ECHO Install the downloaded file and make sure DEVCON.EXE is in the PATH.
   ECHO Then try again.
)

:: Abort if DEVCON.EXE is not available yet
IF "%DevconAvailable%"=="No" GOTO End

:: Patch registry first
CALL UsbRegistryKey.reg

:: List all USB EHCI devices
>> FindEHCI.dat ECHO.%Date%, %Time%
DEVCON listclass USB | FIND "Enhanced" >> FindEHCI.dat
FOR /F "tokens=1 delims=:    " %%A IN ('DEVCON FindAll ^=USB ^| FIND "Enhanced"') DO DEVCON disable "%%A"
ENDLOCAL
GOTO End

:Syntax
ECHO.
ECHO FindDisable_EHCI.bat,  Version 1.00 for Windows 2000 / XP
ECHO Use DEVCON to remove all USB devices and then scan for new devices
ECHO.
ECHO Usage:  USBclass
ECHO.
ECHO Notes:  [1] This batch file requires Microsoft's DEVCON.EXE, available at
ECHO             http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272
ECHO             You will be prompted for download if it isn't found.
:End


Thanks for help



Discussion

No Comment Found