diff --git a/Desktop.Win.Wrapper/Install.ps1 b/Desktop.Win.Wrapper/Install.ps1 index 5acdcae4..8883ce67 100644 --- a/Desktop.Win.Wrapper/Install.ps1 +++ b/Desktop.Win.Wrapper/Install.ps1 @@ -1,6 +1,17 @@ +function Is-Administrator() { + $Identity = [Security.Principal.WindowsIdentity]::GetCurrent() + $Principal = New-Object System.Security.Principal.WindowsPrincipal -ArgumentList $Identity + return $Principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls13 [System.IO.Directory]::CreateDirectory("$env:AppData\Remotely") Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "$env:AppData\Remotely\dotnet-install.ps1" -UseBasicParsing &"$env:AppData\Remotely\dotnet-install.ps1" -Runtime dotnet &"$env:AppData\Remotely\dotnet-install.ps1" -Runtime windowsdesktop -Start-Process -FilePath "dotnet.exe" -ArgumentList "$PSScriptRoot\Remotely_Desktop.dll" -WindowStyle Hidden -Verb RunAs \ No newline at end of file +if (Is-Administrator) { + Start-Process -FilePath "dotnet.exe" -ArgumentList "$PSScriptRoot\Remotely_Desktop.dll" -WindowStyle Hidden -Verb RunAs +} +else { + Start-Process -FilePath "dotnet.exe" -ArgumentList "$PSScriptRoot\Remotely_Desktop.dll" -WindowStyle Hidden +} diff --git a/Server/Attributes/RemoteControlFilterAttribute.cs b/Server/Attributes/RemoteControlFilterAttribute.cs index 1ff99fb7..bbc7f60d 100644 --- a/Server/Attributes/RemoteControlFilterAttribute.cs +++ b/Server/Attributes/RemoteControlFilterAttribute.cs @@ -57,7 +57,7 @@ namespace Remotely.Server.Attributes return; } - context.Result = new UnauthorizedResult(); + context.Result = new RedirectToPageResult("/Account/Login", new { area = "Identity" }); } } }