Issue in execution of batch files Windows XP Pro

M

Marco B

We are experiencing a strange issue related to execution of batch prgogram
from the network. It seems that Windows XP generates big network traffic
executing big batch program (.bat) it seems that the file is trasmitted
across the network for each isntruction containe din the file. If the batch
file is renamed as .cmd it works fine wihtout delay in execution and with no
high network usage.

Many thanks in advance.

Best regards

Marco
 
B

Bob I

You have your answer. ".bat" is for "DOS based" systems, ".CMD" is for
"NT based" systems. Please use .CMD unless you are running Windows 98 or ME.
 
S

Shenan Stanley

Marco said:
We are experiencing a strange issue related to execution of batch
prgogram from the network. It seems that Windows XP generates big
network traffic executing big batch program (.bat) it seems that
the file is trasmitted across the network for each isntruction
containe din the file. If the batch file is renamed as .cmd it
works fine wihtout delay in execution and with no high network
usage.

What's your question?

Seems like an insignificant change - although I cannot say I know why one
would use more network bandwidth than the other, to be honest.

I have been using the *.cmd extension for quite some time.
 
M

Marco B

Hi Bob I, Strange things batch program were running without any issue before
some weeks ago, if you try to use .bat batch program on Windows XP it should
works without any issue. I wouyld like to know if somebody experienced the
same issue, trying to fix the issue without changing the extension of all out
batch programs....

Regards.
 
M

Marco B

Looking by Wireshark to the network traffic I see that the .bat files are
accessed "Random Access". Instead .cm files are accessed "Sequential only"
this happens only on some PC of the networks the ones in which we have the
issue (delay in execution).

Regards.
 
B

Bob I

Using the correct file type IS fixing the issue. What you are wanting is
is to avoid fixing the issue. You may be have the problem as a side
effect of a security update. What you are seeing is an opening and
closing of the file for each command. Simply correcting the extension
will cause desired behaviour.
 
P

Pegasus \(MVP\)

Bob I said:
You have your answer. ".bat" is for "DOS based" systems, ".CMD" is for "NT
based" systems. Please use .CMD unless you are running Windows 98 or ME.

Windoes treats .bat and .cmd files in exactly the same way - no difference
there.
 
P

Pegasus \(MVP\)

Marco B said:
We are experiencing a strange issue related to execution of batch prgogram
from the network. It seems that Windows XP generates big network traffic
executing big batch program (.bat) it seems that the file is trasmitted
across the network for each isntruction containe din the file. If the
batch
file is renamed as .cmd it works fine wihtout delay in execution and with
no
high network usage.

Many thanks in advance.

Best regards

Marco

All batch files, whether you call them .bat or .cmd, work in this way: They
read one line, process one line, then read the next line. If this is an
issue then you should use some script file, e.g. a VB Script file.
 
B

Bob I

Pegasus said:
Windoes treats .bat and .cmd files in exactly the same way - no difference
there.

Humm, I had it in my head that the ".bat" was run under the command.com
while "cmd" runs under cmd.exe
 
P

Pegasus \(MVP\)

Bob I said:
Humm, I had it in my head that the ".bat" was run under the command.com
while "cmd" runs under cmd.exe

There are numerous advanced commands in cmd.exe that would never work in the
legacy command processor "command.com", which the OP should not use (in case
he does). You can use these advanced commands either in .bat or in .cmd
files.
 
M

Marco B

I see you comment, but what we are experiencing is exaclty that .bat files
are executed slowly than .cmd. The difference is taht .bat file generate high
network traffic, looking at the SMB packets it seems that .bat files are
managed with "Random access" and .cmd files are accessed "Sequential only".
I know that this different behaviour is not usual in Windows enviroment....
this is our issue try to understand why we have this differences in files
management at SMB level that generates differences in performance in
execution and high network traffic.

Kind regards.
 
M

Marco B

This is exactly the issue, on some PCs of my network .bat files are treated
differently than .cmd files. I described in other posts the behaviour
looking at the SMB pachets trasferrrend over the network.

Regards.
 
S

Shenan Stanley

Marco said:
Looking by Wireshark to the network traffic I see that the .bat
files are accessed "Random Access". Instead .cm files are accessed
"Sequential only" this happens only on some PC of the networks the
ones in which we have the issue (delay in execution).

The only 'difference' I know of...

The *.bat extentions are executed in a 16bit VDM while *.cmd extentions are
executed in a 32bit VDM. This has implications for scripts that may need to
access shared memory from other processes or applications.

If you have Windows XP or above - you would be better off just utilizing
*.cmd.
 
P

Pegasus \(MVP\)

Shenan Stanley said:
The only 'difference' I know of...

The *.bat extentions are executed in a 16bit VDM while *.cmd extentions
are executed in a 32bit VDM. This has implications for scripts that may
need to access shared memory from other processes or applications. --
Shenan Stanley
MS-MVP

I disagree with your claim: Running a .bat file will NOT invoke the Virtual
DOS Machine. You can easily demonstrate it like so:
1. Open a Command Prompt.
2. Make sure that ntvdm.exe is not running.
3. Run a simple .bat file, e.g. with the command "dir c:\" inside.
4. Check if ntvdm is running. It isn't on my machine.
5. Run, then terminate debug.exe. This is a 16-bit application.
6. Check if ntvdm is running. It now is on my machine.

This confirms your claim that 16-bit applications will launch the ntvdm
process. It also confirms (in my opinion) that .bat files are not handled by
the ntvdm.

If you disagree then I'd like to see some repeatable process that supports
your claim.
 
P

Pegasus \(MVP\)

Marco B said:
I see you comment, but what we are experiencing is exaclty that .bat files
are executed slowly than .cmd. The difference is taht .bat file generate
high
network traffic, looking at the SMB packets it seems that .bat files are
managed with "Random access" and .cmd files are accessed "Sequential
only".
I know that this different behaviour is not usual in Windows
enviroment....
this is our issue try to understand why we have this differences in files
management at SMB level that generates differences in performance in
execution and high network traffic.

Kind regards.

I ran some tests of my own and was unable to confirm your claim. I suspect
there is something else that's leading you to suspect a difference between
..bat and .cmd files, e.g.
- You're not specifying the full path, name and extension of the file you're
executing, hence you might run something other than what you think you're
running.
- Your batch/command file calls itself but again the "call" commands do not
specify a full path, name and extension.
- Your measurements are contaminated by network traffic not generated by
your command/batch file.
- Your virus scanner/firewall treats your .bat/.cmd files differently.

I would perform these tests on a clean Windows machine that is free from the
various types of third-party software.

If you post your batch file then someone will have a closer look at it.
 
S

Shenan Stanley

Pegasus said:
I disagree with your claim: Running a .bat file will NOT invoke the
Virtual DOS Machine. You can easily demonstrate it like so:
1. Open a Command Prompt.
2. Make sure that ntvdm.exe is not running.
3. Run a simple .bat file, e.g. with the command "dir c:\" inside.
4. Check if ntvdm is running. It isn't on my machine.
5. Run, then terminate debug.exe. This is a 16-bit application.
6. Check if ntvdm is running. It now is on my machine.

This confirms your claim that 16-bit applications will launch the
ntvdm process. It also confirms (in my opinion) that .bat files are
not handled by the ntvdm.

If you disagree then I'd like to see some repeatable process that
supports your claim.

Nah - Actually didn't care that much initially - much less now. I'll
concede.

In fact - seems like it may have changed (or never been true at all)...
http://waynes-world-it.blogspot.com/2008/08/difference-between-bat-and-cmd.html

I'd say *.cmd is still the one people should utilize - if not something
better by now.
 
K

Ken Blake, MVP

Humm, I had it in my head that the ".bat" was run under the command.com
while "cmd" runs under cmd.exe


..bat files can be run under either. I'm not sure about .cmd files.
 
P

Pegasus \(MVP\)

Shenan Stanley said:
Nah - Actually didn't care that much initially - much less now. I'll
concede.

In fact - seems like it may have changed (or never been true at all)...
http://waynes-world-it.blogspot.com/2008/08/difference-between-bat-and-cmd.html

I'd say *.cmd is still the one people should utilize - if not something
better by now.

Your link is intriguing. Unfortunately for the OP it only deals with setting
the %ErrorLevel%. There is no mention of any substantial difference between
..bat/.cmd files in the WinXP environment.
 
M

Marco B

My batch program is the simplest one just a creation of folders on a network
drive and copying a small file (1kb) from the local disc c: to the netwrk
folder just created (like the below code)

md \\<machine-name>\<shared-folder> \<new_folder>
copy c:\<test_file> \\<machine-name>\<shared-folder>\<new_folder>
.......

What we noticed is that bigger is the file batch file (just placing more
text line in the batch file after the command copy) slower is the execution.
Just changing the extension from .bat to .cmd the execution become faster.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top