Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cmd.exe vs. Command.com 1

Status
Not open for further replies.

culleoka

Programmer
May 16, 2002
85
US
I have a number of applications created in VFP 5.0, that I run on my machine(Win2k) on a daily basis. I also have a FP 2.6 for DOS app that I also run on my machine on a daily basis. This is run before any of the VFP stuff.

Another application, created in VFP 5.0, is run on another Win2k machine on a daily basis.

I need to compare the directory of a folder before and after the app is run on the other machine.

I have been using the unix ls and comm commands to do this, but something changed the way those commands operate and I am trying to switch the prog to use 'Run dir > temp1.txt' and again to temp2.txt.

My problem is, when I use the 'run dir' command on my machine, my results are in the format of command.com.
When I use the 'run dir' command on the other machine, my results come back in cmd.exe format.

I thought about using the VFP5 'dir' command, but then I get the results in two columns.

Does anyone know how I can ensure that the 'run dir' command operates under only one or the other(cmd.exe/command.com) programmatically so I can append this data to a '.dbf'? Unless I know which is going to run, I won't know for sure what file structure is needed.

Thanks, in advance for any help.

Pat
 
?GETENV("ComSpec")

Command.com was the ComSpec for DOS through ME. Cmd.exe was the ComSpec for NT systems. The 64 bit version of XP has no support for DOS built in, so I would expect ComSpec to be gone from that OS.

Regards,

Mike
 
I can't believe the command prompt (CMD.EXE) wouldn't be rebuilt to work in WinXP/64bit... it uses WinAPI calls to do all the DIR, COPY, etc, commands. Many (if not all) DOS programs will not work on it, though.
 
Thanks mspratt.

wgcs - under Windows XP ver 5.1, the Command Prompt entry under accessories still exists, and runs DOS commands.

My problem is still how to ensure the 'run dir' command will use either command.com or cmd.exe. I don't care which, it just needs to be consistent from one machine to the next.

Anyone have a suggestion?

Pat
 
VFP's RUN command will use the environment variable COMSPEC to choose what command shell to use (CMD.EXE, COMMAND.COM, NDOS, or whatever it is set to)

You don't have to use RUN, though, and even if you do, you can select a shell:
Code:
cmd = ADDBS(JUSTPATH(GETENV('comspec')))+'COMMAND.COM /C DIR > MyDir.txt'
RUN &cmd

this effectively says: "Use the current comspec (RUN) to run the COMMAND.COM shell (which I assume is in the same folder as the current comspec points to) to run a command ( /C ), which command is "DIR > MyDir.txt"

that is, cmd should evaluate to something like:
C:\WINNT\system32\COMMAND.COM /C DIR > c:\temp\jnkdir.txt


An alternative would be to use ShellExecute to launch your choice of COMMAND.COM or CMD.EXE, handing it the command line, but I don't think that the output piping works through that.
 
Regarding your own development and use between DOS and Windows versions of FoxPro, keep 2 different icons on your desktop. One for Cmd.exe which is the main command line interface (CLI) for XP and Windows 32-bit programs, or Command.com which allows use of the Compatibility Mode, Idle sensitivity, and other features not available in Cmd.exe but which works better with older DOS and 16-bit programs.

dbMark
 
Thanks dbMark, I don't know whether I would have thought of that on my own.
I will file your tip for possible future use.

My problem is that I never know which one(command.cm or cmd.exe) a computer with my app's on it will use. I just wanted a way to ensure that it gave the directory results in a consistent manner.

The apps I have developed must run on Win95, Win98, Win2k, and now we are fielding about thiry WinXP machines to replace the Win98's.

They all run FoxPro 2.6 for DOS apps, which I am starting to convert to VFP 8.0, but still give me inconsistent results with the DOS or Command Prompt, as opposed to the cmd.exe in the newer versions of Windows.

For some reason, my development computer defaults to command.com when I issue the 'run dir' command from VFP 5.0.
So the file structure differs from the results of that command on the different comps. Some give the file names at the beginning(command.com) and some give the file names at the end(cmd.exe). Then, to complicate things even more, the VFP 5.0 'dir *.txt' command gives it's results in two columns.

I guess the real solution for cross-platform use is going to be doing a workaround for the VFP 'dir' command, and stay away from the command.com vs. cmd.exe problem altogether.

On that not, does anyone know of a way to force Visual FoxPro to give it's results in a one column text file instead of two(ex. dir *.txt > temp1.txt)?
Or shoud that be another thread?

Thanks to everyone.

Pat
 
Hi Pat,

In VFP8 will the ADIR() function give you what you need?

Regards,

Mike
 
wgcs

Thanks, for your tip, but I'm still in VFP 5.0, and the Justpath() function is not available there.

I tried the VFP dir command, which gave me results in two columns. Did some tinkering and got it to do what I wanted.

Until I put it on another machine. That machine gave me the results in FOUR columns! Plus, it would fill the screen and give a wait window 'Press any key to continue'.
No Good.

mspratt

ADIR() worked like magic! Thanks! I have the prog up and running correctly on three machines now, an XP and the two Win2k machines that showed me the problem.

Thanks again to everyone! I think I can put this to rest now.

Pat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top