Skip to content

Instantly share code, notes, and snippets.

@barrkel
Created February 5, 2021 12:47
Show Gist options
  • Save barrkel/cadbe8bde8adc3488539953ed208032a to your computer and use it in GitHub Desktop.
Save barrkel/cadbe8bde8adc3488539953ed208032a to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using Windows.Storage.Streams;
using Windows.System.UserProfile;
using Windows.Storage;
using System.Security.AccessControl;
namespace set_lock_screen
{
class Program
{
static async Task SetLockImage(string path)
{
StorageFile file = await StorageFile.GetFileFromPathAsync(path);
await LockScreen.SetImageFileAsync(file);
}
static int Main(string[] args)
{
if (args.Length != 1)
{
Console.Error.WriteLine("usage: {0} <image>", Environment.GetCommandLineArgs()[0]);
return 1;
}
try
{
SetLockImage(Path.GetFullPath(args[0])).GetAwaiter().GetResult();
return 0;
}
catch (Exception ex)
{
Console.Error.WriteLine("Error: {0}", ex.Message);
return 2;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment