barncastle / Battle.Net-Installer

A tool for installing, updating and repairing Blizzard games through Battle.net.
230 stars 42 forks source link

Need to check for Battle.net installed before executing #2

Closed toannhanb7 closed 3 years ago

toannhanb7 commented 3 years ago

Looking at the source code of AgentApp.cs at line 30. After constructing the AgentPath, we directly going to execute the Process without any checking for existing. It leads to an unclear error if there is no Battle.net being installed.

Unhandled exception. System.ComponentModel.Win32Exception (2): The system cannot find the file specified. at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(String fileName, String arguments) at BNetInstaller.AgentApp.StartProcess() at BNetInstaller.AgentApp..ctor() at BNetInstaller.Program.Run(Options options) at BNetInstaller.Program.Main(String[] args) at BNetInstaller.Program.

(String[] args)

It is better if we can have a check and leave a message to let user know the problem ` AgentPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Battle.net", "Agent", "Agent.exe");

        // Check for Battle.net existing in system
        if (!File.Exists(AgentPath))
        {
            Console.WriteLine("Please install Battle.net before running");
            Environment.Exit(1);
        }

`

Thanks

barncastle commented 3 years ago

Thanks for pointing this out, fixed in the latest release