Skip to content

Commit

Permalink
Wrapper working.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Apr 23, 2020
1 parent 149c63b commit 217c759
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Desktop.Win.Wrapper/Desktop.Win.Wrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand Down
3 changes: 2 additions & 1 deletion Desktop.Win.Wrapper/Install.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[System.IO.Directory]::CreateDirectory("$env:AppData\Remotely")
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "$env:AppData\Remotely\dotnet-install.ps1"
&"$env:AppData\Remotely\dotnet-install.ps1" -Runtime dotnet
&"$env:AppData\Remotely\dotnet-install.ps1" -Runtime windowsdesktop
&"$env:AppData\Remotely\dotnet-install.ps1" -Runtime windowsdesktop
Start-Process -FilePath "dotnet.exe" -ArgumentList "$PSScriptRoot\Remotely_Desktop.dll" -WindowStyle Hidden
56 changes: 47 additions & 9 deletions Desktop.Win.Wrapper/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
Expand All @@ -12,6 +16,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using PathIO = System.IO.Path;

namespace Remotely.Desktop.Win.Wrapper
{
Expand All @@ -20,6 +25,7 @@ namespace Remotely.Desktop.Win.Wrapper
/// </summary>
public partial class MainWindow : Window
{
private readonly string tempDir = Directory.CreateDirectory(PathIO.Combine(PathIO.GetTempPath(), "Remotely_Desktop")).FullName;
public MainWindow()
{
InitializeComponent();
Expand All @@ -45,27 +51,59 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
ExtractRemotely();
ExtractInstallScript();
RunInstallScript();
RunRemotely();
}

private void RunRemotely()
{
StatusText.Text = "Starting up...";
Close();
}

private void ExtractRemotely()
{
StatusText.Text = "Extracting files...";
try
{
StatusText.Text = "Extracting files...";
var zipPath = PathIO.Combine(tempDir, "Remotely_Desktop.zip");
using (var mrs = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("Remotely.Desktop.Win.Wrapper.Remotely_Desktop.zip"))
{
using (var fs = new FileStream(zipPath, FileMode.Create))
{
mrs.CopyTo(fs);
}
}
ZipFile.ExtractToDirectory(zipPath, tempDir);
}
catch { }
}

private void RunInstallScript()
{
StatusText.Text = "Updating .NET Core runtime...";
try
{
StatusText.Text = "Updating .NET Core runtime...";
var installPath = PathIO.Combine(tempDir, "Install.ps1");
Process.Start(new ProcessStartInfo()
{
FileName = "powershell.exe",
Arguments = $"-executionpolicy bypass -f \"{installPath}\"",
WindowStyle = ProcessWindowStyle.Hidden
});
}
catch { }
}

private void ExtractInstallScript()
{

try
{
var installPath = PathIO.Combine(tempDir, "Install.ps1");
using (var mrs = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("Remotely.Desktop.Win.Wrapper.Install.ps1"))
{
using (var fs = new FileStream(installPath, FileMode.Create))
{
mrs.CopyTo(fs);
}
}
}
catch { }
}
}
}
8 changes: 4 additions & 4 deletions Server/Pages/Agents.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
<div class="text-info col-sm-12 pl-0 mb-2">
Instant desktop sharing. No account required.
</div>
<div class="col-sm-6 mb-3">
@*<div class="col-sm-6 mb-3">
<h6>Windows (64-Bit)</h6>
<p>
<strong>Download:</strong>
<br />
<a href="~/Downloads/Win-x64/Remotely_Desktop.exe">Windows EXE</a>
</p>
</div>
</div>*@
<div class="col-sm-6">
<h6>Windows (32-Bit)</h6>
<h6>Windows (64/32-Bit)</h6>
<p>
<strong>Download:</strong>
<br />
<a href="~/Downloads/Win-x86/Remotely_Desktop.exe">Windows EXE</a>
<a href="~/Downloads/Remotely_Desktop.exe">Windows EXE</a>
</p>
</div>
<div class="col-sm-6 mb-3">
Expand Down

0 comments on commit 217c759

Please sign in to comment.