Trying to wrap CALL function fails [duplicate] - windows

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.

Related

Waiting for closing of previously started program

I would like to ask you how to specify waiting for closing of specific program which was started before. I am showing here an example with command waitfor but unfortunately I don't know how to write it correctly, therefore I am asking you for help.
system('"C:\Program Files\Google\Chrome\Application\chrome.exe" &');
waitfor "closing of chrome.exe"
You should follow the advice in this other Q&A to find the PID of the new program right after you start it. Then, in a loop, check to see if that PID is still running (using again the same process as before), and pause(1) to avoid checking too frequently.
I guess you can do something like:
time_in_seconds=60
while ~isfile("output_folder/file.db")
pause(time_in_seconds)
end
Note that this program, as is, requires that file to exist at some point, otherwise infinite loop. Make sure you put safeguards to end it in case the file does not get created (like a time limit).
But I am not sure it makes sense to have MATLAB waiting for 40 minutes for a script to finish...

Make a command affect another running batch file

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.

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 do I make a task run on startup through raimeter?

I want a random number to be generated every time I start my computer so I can randomly choose a background on rainmeter. Every time I try to search for an answer I keep getting pages for how to make rainmeter run on startup.
You can use the RunCommand plugin to execute a command line input.
To make it run once when the skin is loaded, you just need to set option UpdateDivider=-1.
The following opens Notepad on startup, replace it in Parameter=Notepad with the command you wish to run.
[Rainmeter]
Update=1000
[MeasureRunCmd]
Measure=Plugin
Plugin=RunCommand
Parameter=Notepad
[MeterRunCmd]
UpdateDivider=-1
Meter=String
Text=None
OnUpdateAction=[!CommandMeasure MeasureRunCmd "Run"]
If you don't need the extra flexibility of that plugin you can just use the following
[Rainmeter]
Update=1000
[MeterRunCmd]
UpdateDivider=-1
Meter=String
Text=None
OnUpdateAction=["Notepad"]
I just became acquainted with Rainmeter about 3 hours ago. But here's a thought:
Any "app" (or even a shortcut to an app) that's in "C:\Users\\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" will run at ... uhh? ... STARTUP! (that's it!). Now, since cmd.exe runs as conhost.exe before the startup folder is processed, that means we can use the "DOS" (I'm an old fart) %RANDOM% variable.
So, if Rainmeter can handle system variables in ".ini" files then you can use %Random% directly (Enter %RANDOM% at the command prompt and you'll see a different number returned everytime). Also, Google %RANDOM% (case, like size, does matter) to see the tweaks used to get any range of numbers you desire.
If Rainmeter can't handle system variables directly then write a 1 line ".bat" file that "set"s the random number to a string (or whatever you can use) and stick the batch file (or a shortcut to it) in the startup folder.
I can't think of a reason why this easy method (or your own enhanced version of it) won't work.
Good luck. Interesting idea. Let me know how you make out.

(MS-DOS) Time Delays

I came past a few ways to cause a time delay such as pings and dirs. Though none of them are really precise, is there anny proper way to cause a time delay?
I heard about a few things though they don't work on all computers, not on my Windows XP nor the Windows NT at college.
It takes ages going through all files on Google finding a good answer, and since I didn't yet find the question on Stack Overflow I thought it might be good to just create the question myself ;)
Sleep
It will allow you to do this.
<warning>This is a hack</warning>
Use your favorite programming language (other than MS-DOS batch) and create an application which takes one argument, the number of milliseconds to wait, then, simply call this program from a batch file to sleep the required amount.
As far as I know, this is the only reliable way to do it in DOS.
If you don't have the ability to send another program along with the batch file, use DEBUG to write a sleep command on the fly, and execute it.
EDIT:
The above answer was kind of toungue-in-cheek. I wouldn't run a batch file that had some DEBUG trickery in it. I believe the traditional way to use a delay in a batch file is the CHOICE commad.
type nul|choice /c:y /t:y,nn > nul
Which of course, doesn't work in XP, since that would be WAAYY too convenient.
"...proper way...."
you can't do that in DOS.
It is possible to achieve a precision of a few miliseconds, depending on your machine's speed.
I have just finished creating such a batch, and though I won't share with you the actual code, I'll give you some pointers:
Use %time% variable, and devide into substrings (without ":" and ".") - one substring will get the seconds, the other - minutes (you may add hours, for delays of over an hour, and even incorporate the date)
Use set /A to transform the time variables into 1 integer representing the amount of seconds which have passed since a rounded hour (X:00:00.00). Add the inputed delay (in seconds) to that.
Create a short loop, comparing the value of the combined var (explained in section 2) to the current time (need to recalc the curent combined min+sec value, inside this loop), and exiting the loop when the match is true.
One major bugfix here - you'll need to truncate any preceeding zeros to variables which are about to get evaluated in a "set /A" command. I've noticed that the console's evaluator (for this command) returns an error when an integer with a preceeding 08 or 09 (or simply 08 or 09) is used.
Remark:
This will only work with command extensions enabled. To test it, use the following at the beginning of the routine:
verify other 2>nul
setlocal enableextensions
if errorlevel 1 goto err
And then add an error handler subroutine named "err".
If you'd want to continue your batch in the same file, use "endlocal" after the looping subroutine.
BTW, this applies ONLY to Windows XP service pack 2 or 3.

Resources