Sourcetree crashing with no error popup upon opening
Asked by Rob B:

I have been a user of Windows Sourcetree for a number of years now. As of late, whenever I try to open Sourcetree, or run the installer, I get the application splash screen for a few seconds, and then it closes itself with no displayed error messages.

The last action I remember taking in Sourcetree before the problem occurred was attempting to clone a repo that had git LFS enabled, which failed (with a popup about lack of LFS support) after which Sourcetree continued working as normal until a presumably unrelated laptop failure to recover from sleep mode.

I was running 3.4.5.0 when the problem occured, but it still occurs with 3.4.10.0 (latest).

Here is the contents of the \`%localappdata%\\Atlassian\\SourceTree\\sourcetree.log\` log file: <https://pastebin.com/frQzGRjC>

Here's the start of that log file:

```
[SourceTree.App] [Log] - Failed to start
System.Management.ManagementException: Invalid class 
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
at SourceTree.UI.Theme.Wpf.Utilities.NativeHelper.GetWindowsVersion()
at SourceTree.UI.Theme.Wpf.Controls.PerMonitorDpiWindow.OnSourceInitialized(EventArgs e)
at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.ShowDialog()
at SourceTree.UI.WelcomeWizardManager.Run()
at SourceTree.UI.OnboardingManager.Run()
at SourceTree.AppRoot.Onboard()
at SourceTree.AppRoot.OnboardIfRequired()
at SourceTree.AppRoot.<OnStartup>d__24.MoveNext()
```

I have already reviewed these posts:

* <https://community.atlassian.com/t5/Sourcetree-questions/Sourcetree-crashing-on-startup/qaq-p/170659>
* <https://confluence.atlassian.com/sourcetreekb/sourcetree-crashes-on-startup-831655339.html>
* <https://community.atlassian.com/t5/Sourcetree-questions/SourceTree-crashes-on-startup/qaq-p/1468052>
* <https://community.atlassian.com/t5/Sourcetree-questions/Sourcetree-crashing-on-startup/qaq-p/170659>

I have already tried these fixes:

* Restarting my computer
* Installing a newer version of sourcetree (3.4.5.0 -\> 3.4.10.0). The installer similarly brings up a splash screen and then does nothing, but it does install a copy of sourcetree (that then fails to open when launched)
* Deleting the user-specific configuration files mentioned here: <https://confluence.atlassian.com/sourcetreekb/how-to-wipe-sourcetree-preferences-412484640.html>
* Completely deleting the \`%localappdata%\\Atlassian\` folder
* Completely deleting the \`%localappdata%\\Sourcetree\` folder


Answers:
author: Rob B
body: What a troublesome issue... I think the true cause was something going wrong on Windows' side of things during an update or unexpected shutdown. No changes were required to any Sourcetree related files to fix this issue.

By googling the error message:

```
Invalid class at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
```

I was able to track down the following articles:

* <https://knowledge.broadcom.com/external/article/184940/getting-error-management-exception-deta.html>
* <https://www.virtuallyboring.com/microsoft-wmi-invalid-class-error-0x80041010/>
* <https://docs.ukfast.co.uk/operatingsystems/windows/commonissues/wbem.html>

My WMI was indeed broken and the local control properties were displaying as "Invalid Class".

In order to fix this, I downloaded the WMIDiag tool. Most of the downloads I could find were a version that did not support Windows 10, but I found 2.1 which did support Windows 10 here: <https://www.softpedia.com/get/Tweak/System-Tweak/WMIDiag.shtml#download>

This confirmed the issue was due to MOF Registration errors.

Then I ran a modified version of the command from the virtuallyboring article linked above.

In an admin command prompt:

1.

   ```
   cd C:\Windows\System32\wbem
   ```

2.

   ```
   dir /b *.mof *.mfl | findstr /v /i uninstall > moflist.txt & for /F %s in (moflist.txt) do mofcomp %s
   ```

This went through and reinstalled all of the MOF packages that were broken according to the WMI log. I checked the WMI control panel and it no longer displayed Invalid Class, and Sourcetree was able to open again. No computer restart needed.

comments: author: Nathanieljla
body: Thanks for the lead. It looks like this was addressed elsewhere

<br />

<https://community.atlassian.com/t5/Sourcetree-questions/SourceTree-crashes-on-launch/qaq-p/614185>

Which lead to this (and worked for me)

<https://community.spiceworks.com/how_to/21413-rebuilding-the-wmi-repository>