mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
[MWB]Work without service if service doesn't start (#26521)
This commit is contained in:
@@ -86,15 +86,25 @@ namespace MouseWithoutBorders.Class
|
||||
|
||||
// If we're started from the .dll module or from the service process, we should
|
||||
// assume the service mode.
|
||||
if (serviceMode || runningAsSystem)
|
||||
if (serviceMode && !runningAsSystem)
|
||||
{
|
||||
if (!runningAsSystem)
|
||||
try
|
||||
{
|
||||
var sc = new ServiceController(ServiceName);
|
||||
sc.Start();
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Common.Log("Couldn't start the service. Will try to continue as not a service.");
|
||||
Common.Log(ex);
|
||||
serviceMode = false;
|
||||
Setting.Values.UseService = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (serviceMode || runningAsSystem)
|
||||
{
|
||||
if (args.Length > 2)
|
||||
{
|
||||
Helper.UserLocalAppDataPath = args[2].Trim();
|
||||
|
||||
@@ -979,6 +979,30 @@ namespace MouseWithoutBorders.Class
|
||||
}
|
||||
}
|
||||
|
||||
// If starting the service fails, work in not service mode.
|
||||
internal bool UseService
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
return _properties.UseService;
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
lock (_loadingSettingsLock)
|
||||
{
|
||||
_properties.UseService = value;
|
||||
if (!PauseInstantSaving)
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool SendErrorLogV2
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user