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?
Related
I'm trying to get a bat file together and not sure how to run multiple cmd lines through the .bat.
Objective: I want to be able to click on this .bat file to open cmd prompt, then to find a "folder" in the directory, rename the "Folder" then move the location of the folder then find a existing Folder and put it in the same directory.
Problem: i know how to run these cmds in the prompt without an issues.
So far this is what i have:
#echo off
start cmd.exe /k cd %AppData%\Microsoft\Network\Connections
#echo off
and then just write your commands its that simple
A .bat file is executed in a terminal window automatically, you don't need to call cmd.exe or anything like that.
Every single line you write in the .bat file is going to be executed one by one, so you just need to write multiple lines with all the instructions and then you can double click on your new file to run the script.
If you are not familiar with Windows commands for the terminal, you can find more info on the web about how to find a folder, rename it, etc. There are many things you can do by command line and this is not the right place to explain how to use them.
I have created a windows batch file to run a code which is located in a particular folder. However, I am running the batch file but it does not work. What I want it to do is:
Change working directory in Spyder (Spyder is already openned so I don't want it to open it first)
Run the script I want to execute
Basically, the script I am running is plotting a bunch of graphs and all the files needed to create this are located in the working directory.
#echo off
"C:\Users\Mason\Desktop\WinPython-64bit-2.7.6.4\spyder.exe"
chdir /D "F:\optimisation"
"F:\optimisation\plot.py"
pause
The batch file runs fine without any errors, but nothing happens in Spyder e.g. it doesn't change the working directory and neither executes the code.
I'd suggest
#echo off
setlocal
chdir /D "F:\optimisation"
"C:\Users\Mason\Desktop\WinPython-64bit-2.7.6.4\spyder.exe" "F:\optimisation\plot.py"
pause
That is, switch to the required directory, having set a local environment (this restores the original environment when the batch terminates).
Then run the spyder executable, providing it with the name of the file. It would be normal practice to use this structure to provide a significant filename to an executable (eg notepad fred,txt)
Since the current directory when spyder runs is f:\optimisation, it is probably not necessary to specify the entire path in spyder's argument.
Note this is all just speculation using normal practice. I have no experience of spyder- in fact, this is the first I've heard of it.
I am trying to execute a .bat file from a command line inside an automation program. I have written a .bat file that works when double clicked but the automation app will not execute the file.
Is there a command that can be included in the .bat file to make it execute when the automation program calls it up? Here is the .bat file I wrote:
[LITE BOX HI (BOTH LOW & MEDIUM) - ON]
cd..
cd..
cd C:\denkovi\drcltjarorg\
java -jar denkovirelaycommandlinetool.jar DAE001x0 8 4 1
java -jar denkovirelaycommandlinetool.jar DAE001x0 8 6 1
Thanks for any ideas.
Ron
First try adding "pause" to the bottom of the BAT script to see if there are any errors.
Also verify if the path of the executable you are calling is in the PATH variable for the computer.
Make sure the relevant JAR's are in the correct directory.
I am vaguely familiar with batch. Super light knowledge. Anyways, I have this program that runs in a command line mode (it happens to render minecraft maps).
It is normally used by opening cmd, and typing mapcrafter.exe -c config.config -j 8 which runs the exe, specifies the config file, and runs the job with 8 threads.
One thing I wanted to do was put all of this in a batch file so I didn't have to type everything in every time I wanted to re-render it. It looked like:
start cmd.exe /K mapcrafter.exe --config "config.config" --jobs 8
This worked great, when the batch file was in the same directory as the exe.
Anyways, what I don't know how to do is to:
Start command prompt
change directory (cd) to the folder containing the .exe
Run the .exe with the two (-c -j) parameters
I want to do all of this in one batch file, and I want it to keep the command prompt window open, since the .exe outputs errors and percent completion.
I'm lucky I was able to get the one-line batch file working, with my limited knowledge of batch. At this point, I'm out of ideas as to how I should approach this. Thank you in advance for any help you can offer!
Why don't you just create a batch file with
mapcrafter.exe --config "config.config" --jobs 8
The reason it doesn't work when it is not in the same directory is because your path variable doesn't have the location of mapcrafter. An easier way around would be to use full path something like
D:\MineCraft\mapcrafter.exe --config "config.config" --jobs 8
If you want to learn more about configuring PATH environment variable see
Adding directory to PATH Environment Variable in Windows
you could just make a shortcut of the .bat file and have that on your desktop or wherever you want it. here is Microsoft's support page on this http://support.microsoft.com/kb/140443
I have created a bat file to start a Ruby service
working code is:
ruby C:\folder\Projects\folder\folder\script\server
It works fine when I open a command prompt ,paste it and run.
but not working when I created a bat file of it.
bat content is
ruby C:\folder\Projects\folder\folder\script\server
pause
when I run that bat file, it not working as expected. It runs multiple as shown below.
Please help me to resolve it.
The Batch file must have a name different than the process you want to run in it. In this case, the Batch file must not be named ruby.bat, because in this case, the line:
ruby C:\folder\Projects\folder\folder\script\server
placed in the Batch file imply a recursive invocation of itself...