Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Oculus Killer Installer #66

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions OculusKiller/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
Binary file added OculusKiller/Assets/bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OculusKiller/Assets/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions OculusKiller/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

175 changes: 175 additions & 0 deletions OculusKiller/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
using System;
using System.Diagnostics;
using System.IO;
using System.ServiceProcess;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;

namespace OculusKillerInstaller
{
public partial class Form1 : Form
{

string directory = "";
int canStart = 0;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

Process[] pname = Process.GetProcessesByName("OVRServer_x64");
if (pname.Length == 0)
{
label2.Text = "Please start Oculus link APP !";
closeAPPAsync();
return;
}
else
{
directory = pname[0].MainModule.FileName;
directory = Path.GetFullPath(Path.Combine(directory, @"..\..\"));
directory += "oculus-dash\\dash\\bin";
}

if (directory == "") // check if directory exist
{
label2.Text = "OCULUS DIRECTORY IS NOW AVAILABLE, PLEASE START OCULUS LINK APP !";
closeAPPAsync();
return;
}

canStart = 1;
}

private void Form1_MouseDown(object sender, MouseEventArgs e)
{
MoveForm.MouseDown(sender);
}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
MoveForm.MouseMove(sender);
}

private void Form1_MouseUp(object sender, MouseEventArgs e)
{
MoveForm.MouseUp();
}

private void Form1_Shown(object sender, EventArgs e)
{
if (canStart == 1)
{
startAsync();
}
}

public async Task closeAPPAsync()
{
int val = 6;
while (val >= 0)
{
val -= 1;
await Task.Delay(1000);
label2.Text = "Closing App in : " + val + "s";
}
Environment.Exit(0);
}

public async Task startAsync()
{

string nameAPP = "/OculusDash.exe";
string nameAPPBACKUP = "/OculusDash.exe";

try
{

if (AppDomain.CurrentDomain.BaseDirectory.Contains(@"Oculus\Support\oculus-dash\dash\bin") == false) //if APP is running inside the directory don't need to copy file
{

//CHECK IF SERVICE IS RUNNING
ServiceController service = new ServiceController("OVRService");
if ((service.Status.Equals(ServiceControllerStatus.Stopped)) ||
(service.Status.Equals(ServiceControllerStatus.StopPending))) { }
else service.Stop();

while (true)
{
service = new ServiceController("OVRService");
if (service.Status == ServiceControllerStatus.Stopped)
{
if (File.Exists(directory + nameAPPBACKUP) == false)
{
File.Move(directory + nameAPP, directory + nameAPPBACKUP); //BACKUP FILE
}
if (File.Exists(directory + nameAPP))
{
File.Delete(directory + nameAPP);
}

File.Copy(AppDomain.CurrentDomain.FriendlyName, directory + nameAPP);

break;
}
}
}

label2.Text = "Getting OpenVr Path";
await Task.Delay(500);

string openVrPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"openvr\openvrpaths.vrpath");
if (File.Exists(openVrPath))
{

label2.Text = "Getting SteamVR path";
await Task.Delay(500);

var jss = new JavaScriptSerializer();
string jsonString = File.ReadAllText(openVrPath);
dynamic steamVrPath = jss.DeserializeObject(jsonString);

string vrStartupPath = Path.Combine(steamVrPath["runtime"][0].ToString(), @"bin\win64\vrstartup.exe");
if (File.Exists(vrStartupPath))
{
label2.Text = "Checking if app is already running";
await Task.Delay(500);

Process[] pname = Process.GetProcessesByName("vrserver");
if (pname.Length == 0)
{
label2.Text = "Starting SteamVR";
await Task.Delay(500);

Process vrStartupProcess = Process.Start(vrStartupPath);
vrStartupProcess.WaitForExit();
}
else
{
label2.Text = "SteamVR is already running !";
await Task.Delay(500);
closeAPPAsync();
return;
}
}
else
MessageBox.Show("SteamVR does not exist in installation directory.");
}
else
MessageBox.Show("Could not find openvr config file within LocalAppdata.");

closeAPPAsync();
return;
}
catch (Exception e)
{
MessageBox.Show($@"An exception occured while attempting to find SteamVR!\n\nMessage: {e}");
}
}
}
}