diff --git a/Desktop.Win.Wrapper/Desktop.Win.Wrapper.csproj b/Desktop.Win.Wrapper/Desktop.Win.Wrapper.csproj index 98848ef93..d142b02f2 100644 --- a/Desktop.Win.Wrapper/Desktop.Win.Wrapper.csproj +++ b/Desktop.Win.Wrapper/Desktop.Win.Wrapper.csproj @@ -154,7 +154,9 @@ if $(ConfigurationName) == Debug ( - echo > $(ProjectDir)Remotely_Desktop.zip + if not exist "$(ProjectDir)Remotely_Desktop.zip" ( + echo > $(ProjectDir)Remotely_Desktop.zip + ) ) \ No newline at end of file diff --git a/Desktop.Win/App.xaml.cs b/Desktop.Win/App.xaml.cs index 27b39b734..6947e2a13 100644 --- a/Desktop.Win/App.xaml.cs +++ b/Desktop.Win/App.xaml.cs @@ -25,15 +25,15 @@ private void Application_Startup(object sender, StartupEventArgs e) { if (Environment.GetCommandLineArgs().Contains("-elevate")) { - var filePath = Process.GetCurrentProcess().MainModule.FileName; + var commandLine = Win32Interop.GetCommandLine().Replace(" -elevate", ""); - Logger.Write($"Elevating process {filePath}."); + Logger.Write($"Elevating process {commandLine}."); var result = Win32Interop.OpenInteractiveProcess( - filePath, + commandLine, -1, false, "default", - false, + true, out var procInfo); Logger.Write($"Elevate result: {result}. Process ID: {procInfo.dwProcessId}."); Environment.Exit(0); diff --git a/Desktop.Win/MainWindow.xaml b/Desktop.Win/MainWindow.xaml index ee278b633..60ad590a3 100644 --- a/Desktop.Win/MainWindow.xaml +++ b/Desktop.Win/MainWindow.xaml @@ -97,9 +97,9 @@ - - - + + + diff --git a/Desktop.Win/ViewModels/MainWindowViewModel.cs b/Desktop.Win/ViewModels/MainWindowViewModel.cs index 817f94589..54ef8b29b 100644 --- a/Desktop.Win/ViewModels/MainWindowViewModel.cs +++ b/Desktop.Win/ViewModels/MainWindowViewModel.cs @@ -72,11 +72,16 @@ public ICommand ElevateToAdminCommand { try { - var filePath = Process.GetCurrentProcess().MainModule.FileName; - var psi = new ProcessStartInfo(filePath) + //var filePath = Process.GetCurrentProcess().MainModule.FileName; + var commandLine = Win32Interop.GetCommandLine().Replace(" -elevate", ""); + var sections = commandLine.Split('"', StringSplitOptions.RemoveEmptyEntries); + var filePath = sections.First(); + var arguments = string.Join('"', sections.Skip(1)); + var psi = new ProcessStartInfo(filePath, arguments) { Verb = "RunAs", - UseShellExecute = true + UseShellExecute = true, + WindowStyle = ProcessWindowStyle.Hidden }; Process.Start(psi); Environment.Exit(0); @@ -103,9 +108,13 @@ public ICommand ElevateToServiceCommand WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true }; - var filePath = Process.GetCurrentProcess().MainModule.FileName; - Logger.Write($"Creating temporary service with file path {filePath}."); - psi.Arguments = $"/c sc create Remotely_Temp binPath=\"{filePath} -elevate\""; + //var filePath = Process.GetCurrentProcess().MainModule.FileName; + var commandLine = Win32Interop.GetCommandLine().Replace(" -elevate", ""); + var sections = commandLine.Split('"', StringSplitOptions.RemoveEmptyEntries); + var filePath = sections.First(); + var arguments = string.Join('"', sections.Skip(1)); + Logger.Write($"Creating temporary service with file path {filePath} and arguments {arguments}."); + psi.Arguments = $"/c sc create Remotely_Temp binPath=\"{filePath} {arguments} -elevate\""; Process.Start(psi).WaitForExit(); psi.Arguments = "/c sc start Remotely_Temp"; Process.Start(psi).WaitForExit(); diff --git a/Server/wwwroot/scripts/Sound.js b/Server/wwwroot/scripts/Sound.js index 3b5ca3e25..657cd72a8 100644 --- a/Server/wwwroot/scripts/Sound.js +++ b/Server/wwwroot/scripts/Sound.js @@ -2,12 +2,23 @@ export const Sound = new class { constructor() { this.AudioElements = new Array(); this.SourceNodes = new Array(); - this.Context = new AudioContext(); + if (AudioContext) { + this.Context = new AudioContext(); + } + else if (window["webkitAudioContext"]) { + this.Context = new window["webkitAudioContext"]; + } + else { + return; + } this.BackgroundAudio = new Audio(); this.BackgroundNode = this.Context.createMediaElementSource(this.BackgroundAudio); this.BackgroundNode.connect(this.Context.destination); } Play(buffer) { + if (!this.Context) { + return; + } var fr = new FileReader(); fr.onload = async (ev) => { var audioBuffer = await this.Context.decodeAudioData(fr.result); diff --git a/Server/wwwroot/scripts/Sound.js.map b/Server/wwwroot/scripts/Sound.js.map index 522a9501b..fe5bbcba7 100644 --- a/Server/wwwroot/scripts/Sound.js.map +++ b/Server/wwwroot/scripts/Sound.js.map @@ -1 +1 @@ -{"version":3,"file":"Sound.js","sourceRoot":"","sources":["Sound.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI;IACrB;QAOA,kBAAa,GAA4B,IAAI,KAAK,EAAoB,CAAC;QACvE,gBAAW,GAAuC,IAAI,KAAK,EAA+B,CAAC;QAPvF,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,EAAE,CAAC;QAClC,IAAI,CAAC,eAAe,GAAG,IAAI,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAClF,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC;IAQD,IAAI,CAAC,MAAkB;QAEnB,IAAI,EAAE,GAAG,IAAI,UAAU,EAAE,CAAC;QAC1B,EAAE,CAAC,MAAM,GAAG,KAAK,EAAE,EAAE,EAAE,EAAE;YACrB,IAAI,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,MAAqB,CAAC,CAAC;YAC/E,IAAI,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;YACrD,YAAY,CAAC,MAAM,GAAG,WAAW,CAAC;YAClC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC/C,YAAY,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC,CAAA;QAED,EAAE,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,CAAC,MA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C,WAAW,CAAC,CAAC;YAC/C,YAAY,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC,CAAA;QAED,EAAE,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IAAA,CAAC;CACL,CAAA"} \ No newline at end of file diff --git a/Server/wwwroot/scripts/Sound.ts b/Server/wwwroot/scripts/Sound.ts index a61478439..b93bd27ec 100644 --- a/Server/wwwroot/scripts/Sound.ts +++ b/Server/wwwroot/scripts/Sound.ts @@ -1,8 +1,15 @@ -import { RemoveFromArray } from "./Utilities.js"; - + export const Sound = new class { constructor() { - this.Context = new AudioContext(); + if (AudioContext) { + this.Context = new AudioContext(); + } + else if (window["webkitAudioContext"]) { + this.Context = new window["webkitAudioContext"]; + } + else { + return; + } this.BackgroundAudio = new Audio(); this.BackgroundNode = this.Context.createMediaElementSource(this.BackgroundAudio); this.BackgroundNode.connect(this.Context.destination); @@ -15,6 +22,9 @@ export const Sound = new class { BackgroundNode: MediaElementAudioSourceNode; Play(buffer: Uint8Array) { + if (!this.Context) { + return; + } var fr = new FileReader(); fr.onload = async (ev) => {