Is there a simple but nifty way to run DOS command

  Picklefactory 09:10 18 Nov 2008

I tend to use DOS file compare on a fairly frequent basis, but it is a tad laborious. I'm wondering if there is a relatively idiot capable way of creating a nifty means to run it. (From XP maybe, with some pretty windows etc)
e.g. Is it very difficult to program something in Basic to open an explorer window to select the 2 programs and run the command or maybe run it from Excel where I could create user forms? At present it is all long hand typing.
Any suggestions welcome.

  VoG II 09:59 18 Nov 2008

I'm not really sure what you want to do but this will launch a Command window from Excel:

Sub test()
Dim retval As Variant
retval = Shell("cmd", 1)
End Sub

  Picklefactory 10:11 18 Nov 2008

Hmmm, maybe my question is not well worded ..... as usual.

I use DOS file compare to run comparisons on pairs of CNC machine programs, but it's rather clunky and long winded, but the function is very good for this purpose. My wish to Santa would be to have a nice little executable of some description, to open a window, select the 2 programs via explorer, designate a location for txt file that shows results and run the DOS command. The only reason I mentioned Excel is that a/ I'm reasonably comfortable with Excel (To a certain level) and b/ I was picturing nice user forms or message boxes in my head to operate, but that might be utter rubbish.
Does that make a bit more sense?
This quite possibly might not be a simple thing at all, but, if you don't ask, you don't get.

  VoG II 10:30 18 Nov 2008

This sounds more suited to VB rather than VBA. Unfortunately my VB skills are limited to displaying a message saying 'Hello world'.

If you want to do this in Excel try asking at MrExcel - I think it is doable but it is outside the sort of thing that I can do with Excel.

This will give you a bump anyway.

  Picklefactory 10:37 18 Nov 2008

Yeah, sort of suspected that, but thought I'd ask anyway. A little VB program would be ideal, but I can't even do the 'Hello World' bit.
I'll leave this post open for a while, and see if anyone has any ideas and I'll check Mr Excel too.

  Peter 10:48 18 Nov 2008


I can't help you with anything to do with programming, but I might be able to make the typing a bit less laborious.

When I want to compare two files I open a DOS Prompt window (type CMD or Command at the Start, Run option) and then type in FC and a SPACE at the DOS prompt. I then drag and drop the first file to compare from the Windows Explorer file display. I then click in the DOS window and type in another SPACE after the file name, which by now should have appeared after the FC command. Then I drag and drop the other file name for comparing into the DOS window. Click in the DOS window, press ENTER and the files are compared.

This works for XP, but not for Vista. For some reason the drag and drop file names function has been disabled in Vista. Vista has the "Copy as path" right click function instead.


  Picklefactory 10:59 18 Nov 2008

Well you live and learn. I never knew that was an option. Thank you very much, that indeed is very helpful. Just tried it and it works perfectly. I'll still explore the possibility of something dedicated, as we have a few other people who occasionally use this function, but are really not IT literate at all, but that is an excellent option and improvement if my Santa wish is not granted.
Thanks again.

  Peter 11:05 18 Nov 2008


Glad to be of help Picklefactory. I've posted something similar before, but it seems that it is not a very well know function.


  DieSse 12:48 18 Nov 2008

How about this Excel file compare software?

click here

  Picklefactory 12:50 18 Nov 2008

As VOG™ advised, MrExcel is always great repository for Excel/Access questions. in case it helps anyone, this is the fix. Simply run following code from VBA and all is done exactly as I hoped. All I'll do now is make a nice, clear sheet with some pretty buttons to fire the code.

Resolved and here's the code.

Thanks again folks.

Sub CompareFiles()
Dim varFile1, varFile2, varFile3
varFile1 = Application.GetOpenFilename("All Files (*.*), *.*", , _
"Select first comparison file")
If TypeName(varFile1) = "Boolean" Then Exit Sub
varFile2 = Application.GetOpenFilename("All Files (*.*), *.*", , _
"Select second comparison file")
If TypeName(varFile2) = "Boolean" Then Exit Sub
varFile3 = Application.GetSaveAsFilename(Title:="Specify output file name")
If TypeName(varFile3) = "Boolean" Then Exit Sub
Shell "cmd.exe /k ""fc /n """ & varFile1 & """ """ & varFile2 & """ >""" & varFile3 & """"
End Sub

  Picklefactory 12:54 18 Nov 2008

Cross posted, I'll check those out from curiosity, but above code works beautifully and I have to be careful what sort of comparison is performed. I have some software already that does a comparison, but it is very literal and simply looks at one line number against the same line number in the 2nd program, problem being if someone simply inserts a blank line in one program, the whole thing is out of sync and it generates a difference for ALL lines. DOS file compare function searches for consecutive lines that match and highlights anything different between them.
But thanks also for your time too.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Samsung Galaxy S9 review

Wacom Cintiq Pro 24 and 32 review – hands-on

When is the next Apple event?

Qu’est-ce qu’Amazon Prime ?