Make a command affect another running batch file - windows

I've got two batch files which are running at the same time. Now I need to execute a command in the first batch file, but it will be executed in the second one.
For example, I want to change the color of the second batch program using the first one. If I type in the command color 0a, I want it to be executed in the second batch program.
The batch pseudo code would be like this
execute "goto :a" in "example.bat"
Is this possible?
By the way, I cannot hardcode this stuff and I'm not advanced so if you can please briefly explain what I have to do.

Related

Trying to wrap CALL function fails [duplicate]

I am using the tool 'HTML Match' to compare two HTML files. As I have to compare many files, I create a batch file like the followion. For example, I give only five sets of files.
cd "C:\Program Files\HTML Match"
HTMLMATCH.EXE "D:\Raj\compare1\a1.html" "D:\Raj\compare2\a1.html" "D:\Raj\compare_res\a1.html"
HTMLMATCH.EXE "D:\Raj\compare1\a2.html" "D:\Raj\compare2\a2.html" "D:\Raj\compare_res\a2.html"
HTMLMATCH.EXE "D:\Raj\compare1\a3.html" "D:\Raj\compare2\a3.html" "D:\Raj\compare_res\a3.html"
HTMLMATCH.EXE "D:\Raj\compare1\a4.html" "D:\Raj\compare2\a4.html" "D:\Raj\compare_res\a4.html"
HTMLMATCH.EXE "D:\Raj\compare1\a5.html" "D:\Raj\compare2\a5.html" "D:\Raj\compare_res\a5.html"
When I execute this batch file in a cmd prompt, only the first line, that is, only 'a1.html', gets compared and produces a result. Then execution stops.
Add call in front of the commands you're running.
You can also change this to a for loop, so:
FOR /L %%i in (1,1,5) DO CALL HTMLMATCH.EXE D:\Raj\compare%%i%%\a%%i%%.html D:\Raj\compare%%i%%\a%%i%%.html D:\Raj\compare_res\a%%i%%.html
The answer to your problem is to write CALL HTMLMATCH.EXE (and the rest of the parameters).
Just use CALL in front of every executable command in the batch file.
I was looking for something really similar and tried, I think, all the replies left here but I finally found the solution to my problem!!
In my script I want to check if one process is running, if not, start it (a .exe) and then check if another process is running, if not, start it too (but leave all the programs opened) and the problem is that the first .exe was started but then not moving to the second one because it was waiting until the process ended.
It´s finally working for me with start and the magic comes with...
/separate
it works for me as:
start "program1" /separate program1.exe
other commands
Before it stopped after starting program1 because it was waiting until it was closed, I think, but this was not going to happen because I wanted to leave it opened.
Now with the start /separate it continues with the other commands.
I found it in another forum but the thing is that it´s the manual, /separate is used to start in another memory space.
You don't have to insert quotation marks where there isn't any space mark between.
Try that:
HTMLMATCH.EXE D:\Raj\compare1\a1.html D:\Raj\compare2\a1.html D:\Raj\compare_res\a1.html
Maybe it will solve your issue.

Using java -jar with loop and insert delay on execution

I am using CMD C:\Windows\System32\cmd.exe.
I would like to write a batch file (.bat) or write a command in order to run my java -jar example.jar
and when execution is completed I would like to add a loop to start again and again with the same example.jar until ends but before the loop starts I would like to add delay in milliseconds or minutes etc... between those loops.
PLEASE ADVISE!
Thanks
A
You could write a VBS or Powershell script to handle the pause/sleep/delay aspect, and simply have your batch file call it.
There are also some freeware utilities out there you could find on Google, perhaps search for sleep.exe, etc.
You could code a loop in the batch file but that's a terribly inefficient way to do it. You could record the time before the loop (using environment variable %TIME% or similar approaches), then check the time inside the loop. But if you want a variable amount of hang time, you'll need to code all the conversions and computations yourself -- not the best use of CPU time. But it could be done, if you are constrained against using VBS, PowerShell, or third-party utilities.

run sofware for a fixed time

I am creating a batch file which is calling other batch file. Sometimes the second batch file gives an error (because the license for the software I am running is not found). When the error hits, a window pop ups and I need to close manually (undesirable because it needs to run in a loop).
I would like to call the second batch file and if it didn't finish to run after 90seconds, kill it and go to the next line of my first batch file.
Is that possible?
Pause, sleep, timeout, and a few others can help you.
I would suggest timeout.
timeout /t 90
Here's some more info: http://www.wikihow.com/Delay-a-Batch-File
To do exactly what you want you'll have to work in some logic to decide what to do after the timeout, but you will likely use a loop after that. It depends on the structure of your code. Maybe toggle a boolean variable to determine if you want to go to the top of the script.

How does Oracle SQL*Plus read script files?

Theory question: How does Oracle's SQL*Plus read script files into memory?
It likely does one of these two options:
Opens the file, reads the entire contents into memory, closes the file, and executes the contents from memory.
Opens the file, reads and executes statements sequentially, closes the file.
Does anyone know for sure which method it uses?
Im writing a program that will modify a script, run the script, and then modify again. This will be simplest if I can modify the script even if it is currently running (Option 1). If Option 2, I will have to wait for the script to be done before I modify again.

Redirect command line input to file, then turn over to standard input

I have a command-line program that I would like to launch, execute a few commands automatically, and then turn the input over to the standard input. The problem with using command line input redirection is that as soon as the commands execute, the program quits. Instead of quitting immediately, I'd like to take over control from that point.
Is there any way to do this? I haven't been able to find anything that works.

Resources