mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use exe console type & Add flag support for helper method
This commit is contained in:
parent
ad6d598c4a
commit
764b524ea4
3 changed files with 10 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
|
|
|||
|
|
@ -808,7 +808,7 @@ namespace Flow.Launcher.Infrastructure
|
|||
/// Inspired by <see href="https://github.com/jay/RunAsDesktopUser">
|
||||
/// Document: <see href="https://learn.microsoft.com/en-us/archive/blogs/aaron_margosis/faq-how-do-i-start-a-program-as-the-desktop-user-from-an-elevated-app">
|
||||
/// </summary>
|
||||
public static unsafe bool RunAsDesktopUser(string app, string currentDir, string cmdLine, out string errorInfo)
|
||||
public static unsafe bool RunAsDesktopUser(string app, string currentDir, string cmdLine, bool loadProfile, bool createNoWindow, out string errorInfo)
|
||||
{
|
||||
STARTUPINFOW si = new();
|
||||
PROCESS_INFORMATION pi = new();
|
||||
|
|
@ -916,11 +916,14 @@ retry:
|
|||
fixed (char* cmdLinePtr = $"- {cmdLine}")
|
||||
fixed (char* currentDirPtr = currentDir)
|
||||
{
|
||||
if (!PInvoke.CreateProcessWithToken(hPrimaryToken,
|
||||
0,
|
||||
if (!PInvoke.CreateProcessWithToken(
|
||||
hPrimaryToken,
|
||||
// If you need to access content in HKEY_CURRENT_USER, please set loadProfile to true
|
||||
loadProfile ? CREATE_PROCESS_LOGON_FLAGS.LOGON_WITH_PROFILE : 0,
|
||||
appPtr,
|
||||
cmdLinePtr,
|
||||
0,
|
||||
// If you do not want to create a window for console app, please set createNoWindow to true
|
||||
createNoWindow ? PROCESS_CREATION_FLAGS.CREATE_NO_WINDOW : 0,
|
||||
null,
|
||||
currentDirPtr,
|
||||
&si,
|
||||
|
|
|
|||
|
|
@ -595,6 +595,8 @@ namespace Flow.Launcher
|
|||
Constant.CommandExecutablePath,
|
||||
Environment.CurrentDirectory,
|
||||
$"-StartProcess -FileName {AddDoubleQuotes(filePath)} -WorkingDirectory {AddDoubleQuotes(workingDirectory)} -Arguments {AddDoubleQuotes(arguments)} -UseShellExecute {useShellExecute} -Verb {AddDoubleQuotes(verb)}",
|
||||
false,
|
||||
true, // Do not show the command window
|
||||
out var errorInfo);
|
||||
if (!string.IsNullOrEmpty(errorInfo))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue