Created
February 5, 2021 12:47
-
-
Save barrkel/cadbe8bde8adc3488539953ed208032a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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