1

I need to install a .bat file on windows 10 , x64, but the file does not run when I click it , nither as an admin , is there a solution for this ?

inside the instal.bat is written :

@devcon remove root\mcamvusb
@devcon install mcamvusb.inf root\mcamvusb

which is , there is a devcon.exe file in the same foledr, that instal.bat should run it

Farzad64
  • 163
  • 2
  • 2
  • 12
  • Take off the @ signs and see what output you get, they might be suppressing some useful information, and add `pause` at the end. – Jonno Jan 16 '16 at 13:30
  • Are you saying the batch file doesn't even open, or there was no output? – Jonno Jan 16 '16 at 13:42
  • it doesn't even open – Farzad64 Jan 16 '16 at 13:45
  • Can you try directly from a `cmd` window? – Jonno Jan 16 '16 at 13:47
  • how do I do that ? – Farzad64 Jan 16 '16 at 13:47
  • It would need to be elevated too, for commands like that. – paradroid Jan 16 '16 at 13:49
  • what do you mean paradroid ? – Farzad64 Jan 16 '16 at 14:03
  • @Farzad64, I posted instructions for obtaining a [command prompt](https://en.wikipedia.org/wiki/Command-line_interface#Command_prompt) for someone else at [Obtaining a Command Prompt on a Windows 8 System](http://support.moonpoint.com/os/windows/win8/cmd_prompt.php). The steps are similar for Windows 10; you can type `cmd` in the "I'm Cortana. Ask me anything" field or use the "Method 2" steps, instead. For paradroid's comment that you need to obtain a command prompt with administrator level permissions, be sure you follow the part of right-clicking and selecting "run as administrator". – moonpoint Jan 16 '16 at 16:21
  • @Farzad64, when you get the command prompt, type `install.bat`, if that is the name of the batch file, and then hit Enter to run the batch file. By running it at the command prompt window as Jonno suggested, you may be able to see an error message that will help you to resolve the problem. – moonpoint Jan 16 '16 at 16:26
  • Thank you very much, I did, it gave Error : devon was not distinguished as a bach file or executable file – Farzad64 Jan 16 '16 at 17:02
  • @Farzad64, you will need to use a "change directory" command to make your working directory the one where the batch file is located before you run the batch file, since the default directory for the command prompt is `C:\WINDOWS\system32`. E.g., `cd \Users\JDoe\Documents`, hit Enter, and then type `instal.bat` and hit Enter, if that was the directory where it was located. Or, alternatively, specify the full directory path to the folder where the batch file is located. E.g., you could enter `\Users\JDoe\Documents\instal.bat` and hit Enter to run the batch file from `C:\WINDOWS\system32`. – moonpoint Jan 16 '16 at 17:49
  • thank you moonpoint, but I did the second solution you proposed , windows recognized where the files were and in the end gave error about the devon.exe file – Farzad64 Jan 16 '16 at 18:04
  • 1
    I just noticed the error message you posted was "devon was not distinguished as a bach file or executable file", yet the batch file you posted has dev**c**on, i.e,, it has a "c", but the error message you posted has "devon". Do you have a typo in one of them? You could also try running the executable outside of the batch file, e.g. `C:\Users\JDoe\Documents\devcon remove root\mcamvusb`, substituting the appropriate directory. – moonpoint Jan 16 '16 at 19:06
  • 1
    Also, make sure you have the right `devcon.exe` - under x64 Windows you must run the 64-bit devcon.exe. See [Quick Method to install DevCon.exe?](http://superuser.com/questions/1002950/quick-method-to-install-devcon-exe/1003435#1003435) for options to get it. – dxiv Jan 16 '16 at 23:25
  • devon was a typo sorry , i did the cmd for devcon remove ,just got a message that i did not understand devcon usage : devcon [-r][-m:\\machine] [..] – Farzad64 Jan 16 '16 at 23:51

2 Answers2

1

"there is a devcon.exe file in the same folder, that instal.bat should run it"

devcon.exe is not available in Windows working directory by default, that's why you have to change your working directory to .bat file location (which also includes devcon.exe). To do this, add this line to the first of .bat file (you can suppress /d if the script is located in drive C):

@cd /d "%~dp0"

Which should look like:

@cd /d "%~dp0"
devcon remove root\mcamvusb
devcon install mcamvusb.inf root\mcamvusb
pause
karel
  • 13,390
  • 26
  • 45
  • 52
NetwOrchestration
  • 3,205
  • 2
  • 21
  • 33
0

When an application displays a message in the form you posted when you run it, i.e., devcon [-r][-m:\\machine] <command> [<arg>..] it usually means you did not use the proper syntax for the command, so it is trying to help you by showing you the correct syntax. When things appear in brackets, i.e., between [ and ] it usually means they are optional. E.g., [-r] means you don't always enter -r, but only when it is needed for a particular operation that can be performed by the command. That option will cause devcon to reboot the system, if a reboot is needed after the command is run. Since you are running the command on the system on which you wish it to perform its operations, you don't need to specify -m:\\machine, and it is put between brackets to show that argument to the command is optional.

The install and remove options to devcon in the lines from the batch file that you posted are valid options as shown at Device Console (DevCon.exe) Commands. I don't know whether what you specified in the devcon remove command is valid for your system, but, perhaps it might help to check on whether the version of devcon you are using is the appropriate one for your version of Windows as dxiv suggested in his comment where he noted:

under x64 Windows you must run the 64-bit devcon.exe.

You can check whether you have a 32-bit or 64-bit version of Windows 10 by running the command wmic os get OSArchitecture at a command prompt. You can check whether you have a 32-bit or 64-bit version of an application, such as devcon.exe by right-clicking on it in the Windows File Explorer, then choosing Properties and then clicking on the Compatibility tab. Then check the check box for "Run this program in compatibility mode for". If you see Windows XP listed as an option, then the program is a 32-bit program, not a 64-bit program, since Windows XP compatibility mode is not an option for a 64-bit application.

moonpoint
  • 5,080
  • 2
  • 19
  • 22
  • thank you for your perfect answer, no it seems it's for x64 , and also my windows 10 is x64 , if I eliminate the command devcon remove, would it help ? – Farzad64 Jan 17 '16 at 08:19
  • If the answer is perfect, and is applicable to your system, how does this not answer your question? If you want help you need to clarify your question. – Ramhound Mar 01 '16 at 20:57