Skip to content

Commit 0e7d8bd

Browse files
committed
Handle custom command being whitespace
1 parent 4ed9b53 commit 0e7d8bd

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/ShutdownTimer/Menu.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,24 @@ private void StartButton_Click(object sender, EventArgs e)
140140
form.Title = "Custom Command";
141141
form.Message = "Please enter the command you want to have executed. If you wish to launch a file, just enter the full file path.\n\n" +
142142
"Note: Execution will use this user's permissions.";
143-
ExceptionHandler.Log("Requesting custom command from user...");
144143

144+
ExceptionHandler.Log("Requesting custom command from user...");
145145
var result = form.ShowDialog();
146+
146147
if (result != DialogResult.OK)
147148
{
148149
ExceptionHandler.Log("User declined to enter custom command, aborting start.");
149150
return;
150151
}
151152

152-
ExceptionHandler.Log("Accepted command: \"" + result.ToString() + "\"");
153+
if (String.IsNullOrWhiteSpace(form.ReturnValue))
154+
{
155+
ExceptionHandler.Log("Custom command was null or whitepace, aborting start.");
156+
MessageBox.Show("Custom command field was empty. Please enter a valid command or use a different action!", "Invalid command!", MessageBoxButtons.OK, MessageBoxIcon.Error);
157+
return;
158+
}
159+
160+
ExceptionHandler.Log("Accepted command: \"" + form.ReturnValue + "\"");
153161
command = form.ReturnValue;
154162
}
155163
}
@@ -174,7 +182,6 @@ private void StartButton_Click(object sender, EventArgs e)
174182
startButton.Enabled = false;
175183
actionGroupBox.Enabled = false;
176184
timeGroupBox.Enabled = false;
177-
178185
SaveSettings();
179186

180187
ExceptionHandler.Log("Initiaing countdown start");

0 commit comments

Comments
 (0)