Long delay when I run a command for the first time in a DOS window

2

We run a server (Win2k) with several tools on it. The workstations (XP) all have their PATH set to include that folder.

When we run a tool (e.g. grep) from a DOS box on a workstation, sometimes there is a long delay (up to a minute) before the tool runs. After the delay everything happens as normal. The subsequent runs don't have the delay, even when run from another DOS box.

Any ideas?

* MORE DETAILS*

This scenario always produces the delay. We are working on a tool in a particular folder on the server. The tool is edited and compiled on one workstation in a DOS box that is positioned in the folder where the tool is built, and then run, the delay is always there. The following run is fine. So regenerating the EXE results in the delay.

rossmcm

Posted 2011-08-18T00:34:20.070

Reputation: 1 328

1Time to bust out Procmon. . . – surfasb – 2011-08-18T05:33:13.897

So if you move it to a different directory, there is no more delay? If so, then I wonder if the delay might be related to loading other files in the first directory (prior to re-locating). – Randolf Richardson – 2011-08-18T17:11:36.997

I know was a while ago and you're not still playing with this but anyhow, As a diagnosic step, try set path= <ENTER> then run the command. – barlop – 2012-06-12T11:07:37.707

Answers

3

Windows is logging into the server to see if the command you want is in that folder. After the first time, it's already logged in. We have the same issue opening documents and folders on the server every day.

You may be able to speed it up (in Windows) by running the following command during login:

Net Use \\ServerName

The command will take a minute to process, but it may happen as a background task that the user won't notice. However, I don't know if this will cause "too many connections" issues in your case.

Hand-E-Food

Posted 2011-08-18T00:34:20.070

Reputation: 4 711

See the additional details I have added to the question. The path is not involved as the EXE is in the current folder. – rossmcm – 2011-08-18T01:24:29.803

1

There could be a network location in your path that's timing out -- when you try to run a program from DOS or from the "Run" option in the Start Menu, if the executable or script/batch file isn't first found in the current working directory then each directory listed in the PATH is searched as well.

You can type "PATH" at the DOS window to see if anything outside of drive C: is in the list. If not, then the next suspects could be:

  1. First-time loading of a very large program can be an issue too (because subsequent uses will come from a cache). Do you have a link to the "grep" tool you're using? If it's a small stand-alone program, then this shouldn't be an issue

  2. Slow anti-virus software (very rare)

  3. Disk failures are beginning to develop (get a full backup as soon as possible)

  4. Excessive fragmentation in your file system (easily remedied by running Disk Defragmenter which can be found in: Start Menu -> Programs -> Accessories -> System Tools -> Disk Defragmenter)

Randolf Richardson

Posted 2011-08-18T00:34:20.070

Reputation: 14 002

See the additional details I have added to the question. We chcked the path but it happens when the EXE is in the current folder so presumably the path would not be involved. It seems to be some sort of caching issue. – rossmcm – 2011-08-18T01:27:00.813

+1 for antivirus. Does the server run antivirus software? – boot13 – 2011-08-19T22:49:43.660

1

grep is not a Win32 command but a Unix one, so you may have invoked the Unix subsystem which is present in older versions of Windows.

A special system process must be started to support these Unix commands which can explain for the initial delay. I can't remember the name of the process, but if you use something like Process Explorer, you can see it starting.

Maybe this TechNet series can be of some help. Details about the subsystem can be found in the "Windows Internals" book.

billc.cn

Posted 2011-08-18T00:34:20.070

Reputation: 6 821

See the additional details I have added to the question. It's not the unix grep - it's the Borland one. And it's not confined to grep - that was an example. – rossmcm – 2011-08-18T01:25:50.847

Then it must be the time required to find and login to the server as @Hand-E-Food suggested. You can put that net use into a bat file that runs at startup to speed-up future access. – billc.cn – 2011-08-18T01:31:19.823

@Hand-E-Food, billc.cn - that hasn't solved it. – rossmcm – 2011-08-18T05:19:03.897

According to the documentation of CreateProcess (), the current working directory is consulted way earlier than %PATH%, so the delay should be caused by something in the current directory. Maybe it's antivirus or expired network connection.

– billc.cn – 2011-08-18T23:37:34.750