Add a command line option to your program which runs just that function.
override OnStartup in App.xaml.cs and use StartupEventArgs.Args to get the command line arguments.
Alternatively if your function doesn't need the ui to run you can replace Main, add Program.cs and add
class Program
{
[STAThread]
public static void Main(string[] args)
{
if (runNormally(args))
{
MainWindow mainWindow = new MainWindow();
var app = new Application();
app.Run(mainWindow);
}
else
{
MyFunction(args);
}
}
}
Register the context menu so that it passes the command line arguments to run the correct function.