Install bat file doesn't run on windows 10

15,129

"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
Share:
15,129

Related videos on Youtube

Farzad64
Author by

Farzad64

I am a mechanical engineer ( master)

Updated on September 18, 2022

Comments

  • Farzad64
    Farzad64 over 1 year

    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

    • Jonno
      Jonno over 8 years
      Take off the @ signs and see what output you get, they might be suppressing some useful information, and add pause at the end.
    • Jonno
      Jonno over 8 years
      Are you saying the batch file doesn't even open, or there was no output?
    • Farzad64
      Farzad64 over 8 years
      it doesn't even open
    • Jonno
      Jonno over 8 years
      Can you try directly from a cmd window?
    • Farzad64
      Farzad64 over 8 years
      how do I do that ?
    • Naidim
      Naidim over 8 years
      It would need to be elevated too, for commands like that.
    • Farzad64
      Farzad64 over 8 years
      what do you mean paradroid ?
    • moonpoint
      moonpoint over 8 years
      @Farzad64, I posted instructions for obtaining a command prompt for someone else at Obtaining a Command Prompt on a Windows 8 System. 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
      moonpoint over 8 years
      @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.
    • Farzad64
      Farzad64 over 8 years
      Thank you very much, I did, it gave Error : devon was not distinguished as a bach file or executable file
    • moonpoint
      moonpoint over 8 years
      @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.
    • Farzad64
      Farzad64 over 8 years
      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
    • moonpoint
      moonpoint over 8 years
      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 devcon, 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.
    • dxiv
      dxiv over 8 years
      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? for options to get it.
    • Farzad64
      Farzad64 over 8 years
      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] <command> [<arg>..]
  • Farzad64
    Farzad64 over 8 years
    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 ?
  • Ramhound
    Ramhound about 8 years
    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.