Skip to content

Commit

Permalink
修复 未使用管理员权限带参数运行 Steam 无效 & v2.8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Dec 18, 2022
1 parent a5c49c4 commit 4796bc0
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 19 deletions.
31 changes: 15 additions & 16 deletions src/Common.CoreLib/Properties/ThisAssembly.Version.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
namespace System.Properties
namespace System.Properties;

static partial class ThisAssembly
{
static partial class ThisAssembly
{
/// <summary>
/// 版本号
/// <para>在以下平台中还需要将版本号写入相关的清单文件:</para>
/// <list type="bullet">
/// <item> iOS:\src\ST.Client.Mobile.iOS.App\Info.plist &lt;CFBundleVersion&gt; &lt;CFBundleShortVersionString&gt; </item>
/// <item> Android:\src\ST.Client.Mobile.Droid.App\Properties\AndroidManifest.xml &lt;manifest ... android:versionCode(long递增) android:versionName </item>
/// <item> UWP(DesktopBridge):\src\ST.Client.Desktop.Avalonia.App.Bridge.Package\Package.appxmanifest &lt;Identity ... Version </item>
/// <item> macOS:\packaging\build-osx-app.sh &lt;CFBundleVersion&gt; &lt;CFBundleShortVersionString&gt; </item>
/// </list>
/// </summary>
public const string Version = "2.8.5";
/// <summary>
/// 版本号
/// <para>在以下平台中还需要将版本号写入相关的清单文件:</para>
/// <list type="bullet">
/// <item> iOS:\src\ST.Client.Mobile.iOS.App\Info.plist &lt;CFBundleVersion&gt; &lt;CFBundleShortVersionString&gt; </item>
/// <item> Android:\src\ST.Client.Mobile.Droid.App\Properties\AndroidManifest.xml &lt;manifest ... android:versionCode(long递增) android:versionName </item>
/// <item> UWP(DesktopBridge):\src\ST.Client.Desktop.Avalonia.App.Bridge.Package\Package.appxmanifest &lt;Identity ... Version </item>
/// <item> macOS:\packaging\build-osx-app.sh &lt;CFBundleVersion&gt; &lt;CFBundleShortVersionString&gt; </item>
/// </list>
/// </summary>
public const string Version = "2.8.6";

//public const string InfoVersion = Version + "-beta";
}
//public const string InfoVersion = Version + "-beta";
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="4651ED44255E.47979655102CE"
Publisher="CN=A90E406B-B2D3-4A23-B061-0FA1D65C4F66"
Version="2.8.5.0" />
Version="2.8.6.0" />

<Properties>
<DisplayName>Watt Toolkit</DisplayName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.Management;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using _SR = System.Application.Properties.SR;

namespace System.Application.Services.Implementation;
Expand Down Expand Up @@ -199,15 +201,71 @@ static string GetMachineSecretKey()
/// <returns></returns>
static Process? StartProcessRegedit(string? args) => Process2.Start(Regedit, args, workingDirectory: _windir.Value);

/// <summary>
/// 使用 Explorer 降权运行进程
/// </summary>
/// <param name="fileName"></param>
/// <param name="arguments"></param>
/// <returns></returns>
static Process? StartAsInvokerByExplorer(string fileName, string? arguments = null)
{
if (string.IsNullOrEmpty(arguments))
return StartProcessExplorer($"\"{fileName}\"");
var processName = Path.GetFileNameWithoutExtension(fileName);
var cacheCmdFile = IOPath.GetCacheFilePath(CacheTempDirName, "StartAsInvokerByExplorer", FileEx.CMD);
File.WriteAllText(cacheCmdFile, $"@echo {Constants.HARDCODED_APP_NAME} StartAsInvokerByExplorer{Environment.NewLine}start \"\" \"{fileName}\" {arguments}{Environment.NewLine}exit 0");
File.WriteAllText(cacheCmdFile, $"@echo {Constants.HARDCODED_APP_NAME} StartAsInvokerByExplorer({processName}){Environment.NewLine}start \"\" \"{fileName}\" {arguments}{Environment.NewLine}del %0");
var process = StartProcessExplorer($"\"{cacheCmdFile}\"");
IOPath.TryDeleteInDelay(process, cacheCmdFile);
//if (process != null)
//{
// TryDeleteInDelay(process, cacheCmdFile, processName);
//}
return process;

//static async void TryDeleteInDelay(Process process, string filePath, string processName, int millisecondsDelay = 9000, int processWaitMillisecondsDelay = 9000)
//{
// try
// {
// var waitForExitResult = process.WaitForExit(processWaitMillisecondsDelay);
// if (!waitForExitResult)
// {
// try
// {
// process.KillEntireProcessTree();
// }
// catch
// {

// }
// }
// }
// catch
// {
// millisecondsDelay = 0;
// }
// if (millisecondsDelay > 0)
// {
// var token = new CancellationTokenSource(millisecondsDelay);
// try
// {
// await Task.Run(async () =>
// {
// while (true)
// {
// await Task.Delay(100, token.Token);
// if (Process.GetProcessesByName(processName).Any())
// {
// return;
// }
// }
// }, token.Token);
// }
// catch (TaskCanceledException)
// {

// }
// }
// IOPath.FileTryDelete(filePath);
//}
}

public Process? StartAsInvoker(string fileName, string? arguments = null)
Expand Down

0 comments on commit 4796bc0

Please sign in to comment.