Best way to detect right BC command line in C# or VB.NET program?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jdaniels1313
    New User
    • May 2009
    • 2

    Best way to detect right BC command line in C# or VB.NET program?

    OK, so I have a VB.NET app that shells out to Beyond Compare to compare a couple text files, in the context of Windows Forms application. With the change from BC2 to BC3, obviously hard-coding the "BC2.exe" command line isn't the right approach. Is there a registry value or someplace I can look to get the current command line for Beyond Compare that will work for both BC2 and BC3, and preferably, all future versions?

    What I currently have looks like this; it was quick and dirty and worked at the time.

    Private Shared Function GetCommandLine() As String
    Dim CompareCommandExe As String = "BC2.exe"
    Dim CompareCommandFolder As String = "C:\Program Files\Beyond Compare 2"
    Dim CompareCommandArgs As String = "/FV "
    Dim CompareCommandFilesOrFolders As String = "c:\source.txt c:\dest.txt"
    GetCommandLine = """" & CompareCommandFolder & "\" & CompareCommandExe & """ " & CompareCommandArgs _
    & " " & CompareCommandFilesOrFolders
    End Function
  • Chris
    Team Scooter
    • Oct 2007
    • 5538

    #2
    The path to Beyond Compare 2 is stored in the registry value:
    "HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare\ExePath"

    The path to Beyond Compare 3 is stored in the registry value:
    "HKEY_CURRENT_USER\Software\Scooter Software\Beyond Compare 3\ExePath"
    Chris K Scooter Software

    Comment

    • jdaniels1313
      New User
      • May 2009
      • 2

      #3
      What I am really looking for is a technique that doesn't break from one version of BC to the next. Having to know the version number in the registry key as in the example shown will cause things to break when a new BC version is installed.
      I would like for there to be a default/highest and best Beyond Compare that can be invoked without having to know the specific version. I want to AVOID HARD-CODING VERSION-SPECIFIC INFORMATION into programs, command lines in scripting and TFS integration. That way when we install a new version of Beyond Compare, existing scripts and TFS integration don't break. Sorry to repeat myself so much, but it's important.
      The technique I would suggest is the App Path approach, like Adobe Acrobat Reader uses.
      This is: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\App Paths

      The registry values for Beyond Compare would look something like this:

      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\App Paths\Beyond Compare
      Registry Values:
      (Default): C:\Program Files\Beyond Compare 3\BComp.exe
      Path: C:\Program Files\Beyond Compare 3

      Can we get this type of feature added to the BC installation routines?
      Last edited by jdaniels1313; 21-May-2009, 05:53 PM. Reason: Clarify and ask for action

      Comment

      • Chris
        Team Scooter
        • Oct 2007
        • 5538

        #4
        Thanks for the suggestion. I'll add this to our list for a future release of BC.
        Chris K Scooter Software

        Comment

        • abhiishek
          New User
          • Feb 2016
          • 2

          #5
          Originally posted by Chris
          Thanks for the suggestion. I'll add this to our list for a future release of BC.
          public static int SilentCompare(string file1, string file2)
          {
          if (!(File.Exists(file1) && File.Exists(file2)))
          return 99999999;
          else if(file1.Length != file2.Length)
          return 99999999;
          else
          {
          System.Diagnostics.Process p = new System.Diagnostics.Process();
          p.StartInfo.FileName = Program.BeyondComparePath; //BCOMP.COM path
          p.StartInfo.Arguments ="/qc"+" "+ file1 +" "+ file2;
          p.StartInfo.UseShellExecute = false;
          p.StartInfo.RedirectStandardOutput = false;
          p.StartInfo.CreateNoWindow = true;
          p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
          p.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolde r.MyDocuments);
          p.Start();
          p.WaitForExit();
          return p.ExitCode; //Bcomp returns exit code as in guide
          }

          }

          Comment

          Working...