Bat file service runs many times - batch-file

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...

Related

How to specify in windows batch file to open spyder, change the working directory and run a script?

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.

How write a correctly-working .bat file?

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?

Program opened with batch file won't work

At work I use a bunch of different programs that are located in many different folders that I have to open when I get here. So I've created a batch file that opens all of them for me.
I've run into an issue with one program that's located on a shared network. In my batch file I put
START "" "\\server\path\program.exe"
It loads the program but when I try to navigate the program is doesn't work. I run into an exception error that says it can't find a file on the C drive. But when I load the same program from the folder without the batch file, it works just fine. Any idea what's causing this?
Try specifying the working folder:
START "" /D "\\server\path" "\\server\path\program.exe"
It's documented in the output of start /?.

run bat files in multiple command windows (dos shells)

I am new to working with bat files.
I have a program that basically does the following:
Write multiple bat files in different sub-folders inside a single main folder at once
The program itself utilizes a command :
"start bat_file_name"
( where bat_file_name is derived from the code say bat1,bat2,bat3)
With this the bat files are executed sequentially one after another in single shell. Is there any modification to the above command with which I can run those bat files in different shells or basically run the files in parallel in separate shells?
Any ideas would be helpful.Thanks.
The start command should already do what you need. I've just tried it here and several start commands in a batch file ran in parallel.

How to run several batch files without open shell windows?

I've got some .bat files with start xxx and I need to run them all in another file
so if do start xxx.bat there I will get running xxx and command line shell. I don't need another shell so how to run batch file without opening another shell? or close it's shell after executing.
If I understand correctly, you just want to use call instead of start.
Example:
call xxx.bat

Resources