Auto-Start Server Changes

- added username/password settings to use for the Auto-Start server on Boot task.
- updated support zip with new settings.
This commit is contained in:
Brett Hewitson 2022-08-08 21:43:03 +10:00
parent 5532050c04
commit efbdc77be6
17 changed files with 143 additions and 8 deletions

View file

@ -900,6 +900,12 @@
<setting name="Alert_OnlinePlayerCountChange" serializeAs="String">
<value>Online Player Count:</value>
</setting>
<setting name="TaskSchedulerUsername" serializeAs="String">
<value />
</setting>
<setting name="TaskSchedulerPassword" serializeAs="String">
<value />
</setting>
</ServerManagerTool.Config>
</userSettings>
</configuration>

View file

@ -3189,5 +3189,29 @@ namespace ServerManagerTool {
return ((int)(this["ServicePointManager_SecurityProtocol"]));
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string TaskSchedulerUsername {
get {
return ((string)(this["TaskSchedulerUsername"]));
}
set {
this["TaskSchedulerUsername"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string TaskSchedulerPassword {
get {
return ((string)(this["TaskSchedulerPassword"]));
}
set {
this["TaskSchedulerPassword"] = value;
}
}
}
}

View file

@ -872,5 +872,11 @@
<Setting Name="ServicePointManager_SecurityProtocol" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">3072</Value>
</Setting>
<Setting Name="TaskSchedulerUsername" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="TaskSchedulerPassword" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View file

@ -802,6 +802,11 @@
<sys:String x:Key="GlobalSettings_TaskPriority_AutoShutdownLabel">Auto Shutdown/Restart Task Priority:</sys:String>
<sys:String x:Key="GlobalSettings_TaskPriority_AutoStartLabel">Auto Start Task Priority:</sys:String>
<sys:String x:Key="GlobalSettings_TaskSchedulerUsernameLabel">Task Scheduler Username:</sys:String>
<sys:String x:Key="GlobalSettings_TaskSchedulerUsernameTooltip">This username will be used for the Auto-Start server on Boot task.</sys:String>
<sys:String x:Key="GlobalSettings_TaskSchedulerPasswordLabel">Task Scheduler Password:</sys:String>
<sys:String x:Key="GlobalSettings_TaskSchedulerPasswordTooltip">This password will be used for the Auto-Start server on Boot task.</sys:String>
<sys:String x:Key="GlobalSettings_ResetSettings_ConfirmTitle">Confirm Settings Reset Action</sys:String>
<sys:String x:Key="GlobalSettings_ResetSettings_ConfirmLabel">Click 'Yes' to confirm you want to perform the settings reset.</sys:String>
<sys:String x:Key="GlobalSettings_ResetSettings_FailedTitle">Failed to Reset Settings</sys:String>

View file

@ -4611,7 +4611,7 @@ namespace ServerManagerTool.Lib
var taskKey = GetProfileKey();
if (!TaskSchedulerUtils.ScheduleAutoStart(taskKey, null, this.EnableAutoStart, GetLauncherFile(), ProfileName, this.AutoStartOnLogin, Config.Default.AutoStart_TaskPriority))
if (!TaskSchedulerUtils.ScheduleAutoStart(taskKey, null, this.EnableAutoStart, GetLauncherFile(), ProfileName, this.AutoStartOnLogin, Config.Default.TaskSchedulerUsername, Config.Default.TaskSchedulerPassword, Config.Default.AutoStart_TaskPriority))
{
return false;
}

View file

@ -813,6 +813,8 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="20"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="150"/>
@ -856,6 +858,12 @@
<Label Grid.Row="10" Grid.Column="2" Margin="0" Content="{DynamicResource GlobalSettings_TaskPriority_AutoStartLabel}" VerticalAlignment="Center"/>
<ComboBox Name="TaskPriorityAutoStartComboBox" Grid.Row="10" Grid.Column="3" Margin="1" ItemsSource="{Binding ElementName=GlobalSettings, Path=TaskPriorities}" SelectedValue="{Binding Config.AutoStart_TaskPriority}" ToolTip="{DynamicResource GlobalSettings_TaskPriority_Tooltip}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<Label Grid.Row="12" Grid.Column="0" Content="{DynamicResource GlobalSettings_TaskSchedulerUsernameLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="12" Grid.Column="1" Margin="1" Text="{Binding Config.TaskSchedulerUsername}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_TaskSchedulerUsernameTooltip}"/>
<Label Grid.Row="12" Grid.Column="2" Content="{DynamicResource GlobalSettings_TaskSchedulerPasswordLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="12" Grid.Column="3" Margin="1" Name="HideTaskSchedulerPasswordTextBox" Text="{DynamicResource ServerSettings_HidePasswordText}" IsEnabled="{Binding Config.Email_UseDetaultCredentials, Converter={StaticResource InvertBooleanConverter}}" ToolTip="{DynamicResource ServerSettings_HidePasswordTooltip}" GotFocus="HiddenField_GotFocus" Style="{StaticResource HiddenTextBoxStyle}"/>
<TextBox Grid.Row="12" Grid.Column="3" Margin="1" Name="TaskSchedulerPasswordTextBox" Text="{Binding Config.TaskSchedulerPassword}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_TaskSchedulerPasswordTooltip}" LostFocus="HiddenField_LostFocus" Visibility="Collapsed"/>
</Grid>
</GroupBox>
</Grid>

View file

@ -434,6 +434,8 @@ namespace ServerManagerTool
textBox = EmailPasswordTextBox;
if (Equals(hideTextBox, HideDiscordBotTokenTextBox))
textBox = DiscordBotTokenTextBox;
if (Equals(hideTextBox, HideTaskSchedulerPasswordTextBox))
textBox = TaskSchedulerPasswordTextBox;
if (textBox != null)
{
@ -459,6 +461,8 @@ namespace ServerManagerTool
hideTextBox = HideEmailPasswordTextBox;
if (textBox == DiscordBotTokenTextBox)
hideTextBox = HideDiscordBotTokenTextBox;
if (textBox == TaskSchedulerPasswordTextBox)
hideTextBox = HideTaskSchedulerPasswordTextBox;
if (hideTextBox != null)
{

View file

@ -972,6 +972,14 @@ namespace ServerManagerTool
comment.AppendLine($"ServerShutdown_WorldSaveDelay: {Config.Default.ServerShutdown_WorldSaveDelay}");
comment.AppendLine($"RCON_MessageCommand: {Config.Default.RCON_MessageCommand}");
comment.AppendLine($"AutoBackup_TaskPriority: {Config.Default.AutoBackup_TaskPriority}");
comment.AppendLine($"AutoUpdate_TaskPriority: {Config.Default.AutoUpdate_TaskPriority}");
comment.AppendLine($"AutoShutdown_TaskPriority: {Config.Default.AutoShutdown_TaskPriority}");
comment.AppendLine($"AutoStart_TaskPriority: {Config.Default.AutoStart_TaskPriority}");
comment.AppendLine($"TaskSchedulerUsername: {Config.Default.TaskSchedulerUsername}");
comment.AppendLine($"HasTaskSchedulerPassword: {!string.IsNullOrWhiteSpace(Config.Default.TaskSchedulerPassword)}");
var zipFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), this.Settings.ProfileID + ".zip");
if (File.Exists(zipFile)) File.Delete(zipFile);