/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App.Storage/Windows/Helpers/WindowsStorableHelpers.PowerShell.cs
39 строк
1 KB
yair100
Code Quality: Updated headers
01 июл 2026, 06:18
01 июл 2026, 06:18
c27305a
Код
Авторство
О чём код?
// Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 namespace Files.App.Storage { public static partial class WindowsStorableHelpers { public static async Task<bool> TrySetShortcutIconOnPowerShellAsElevatedAsync(this IWindowsStorable storable, IWindowsStorable iconFile, int index) { string psScript = $@"$FilePath = '{storable}' $IconFile = '{iconFile}' $IconIndex = '{index}' $Shell = New-Object -ComObject WScript.Shell $Shortcut = $Shell.CreateShortcut($FilePath) $Shortcut.IconLocation = ""$IconFile, $IconIndex"" $Shortcut.Save()"; var process = new Process() { StartInfo = new ProcessStartInfo() { FileName = "PowerShell.exe", Arguments = $"-NoProfile -EncodedCommand {Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(psScript))}", Verb = "RunAs", CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = true }, }; process.Start(); await process.WaitForExitAsync(); return true; } } }