0

I have three commands that should be executed in a batch file. When I execute them manually, I don't have any problems, but in a .bat file, they don't work anymore...

First, a python virtual environment should start. Second, a python script should be executed. And last but not least: an mbedded webbrowser should be started.

The commands below work well while manually-executed, but not in the batch fil I created.

I have to following code in my batch file:

@echo off
dikopy\scripts\activate
python system\www\index.py
system\phpdesktop-chrome

What is wrong here? How can I make it work?

  • Instead of "It doesn't work" it would be more helpful to describe explicitely what happened and what you want to happen – akraf Jan 06 '18 at 13:22
  • @akraf When I execute the batch file, it doesn't do anything. When I execute it using cmd, it just opens a new cmd window... – Jordy Deweer Jan 06 '18 at 13:41
  • You could temporarily remove the `@echo off` line. Then you can see "the computer entering the commands into the prompt". You could then check if it looks the same (also what folder name is before the `>` prompt) as when you entered the commands yourself. – akraf Jan 06 '18 at 13:45
  • Please take a look on [What is the reason for '...' is not recognized as an internal or external command, operable program or batch file?](https://stackoverflow.com/a/41461002/3074564) which is the error message output two or even three times on running your batch file with a double click. Best would be to specify all four file names with complete path and file extension in the batch file enclosed in double quotes. See also [debugging a batch file](https://stackoverflow.com/a/42448601/3074564). And save the batch file as __ANSI__ file and not as __Unicode__ file on using Notepad. – Mofi Jan 06 '18 at 13:46
  • When you say "execute them manually" in your question, do you mean double-click or via the command line? If you used double-click, try to get a working result first by typing the commands manually into the command line (and document here what happened if it does not work) – akraf Jan 06 '18 at 13:50
  • Another idea, just into the blue... did you perhaps not make Windows show file extensions, so that you saved your file accidentially as "script.bat.txt" and not as "script.bat"? – akraf Jan 06 '18 at 13:51
  • @akraf I saved the as .bat, as needed :) I also executed them by typing them in a command prompt. I did that before I created the batch file, as I would like to be sure about my commands first. – Jordy Deweer Jan 06 '18 at 13:59
  • @akraf It just opens a new command prompt, without showing any commands. I see that the correct folder is shown: C:\Users\jordy\dikotest> which is correct. – Jordy Deweer Jan 06 '18 at 14:04
  • This is strange... it should at least print the contents of the file to the prompt if `@echo on` or no `@echo ...` is set... Can you prepend "Echo" to each of the three commands (causing them to be printed instead of executed) and add a `pause` command at the end to see if the lines are executed at all? – akraf Jan 06 '18 at 14:08
  • @mofi I don't get an error saying that the programs don't exist... I just get a new cmd... Enclosing file paths between brackets doesn't help. – Jordy Deweer Jan 06 '18 at 14:10
  • I think that I found the problem: It is because of the Python virtual environment... That starts and changes cmd prompt properties... and the script stops working because of that. – Jordy Deweer Jan 06 '18 at 14:23

0 Answers0