コード例 #1
0
        private void InstallButton(object sender, RoutedEventArgs e)
        {
            if (DriverVersion.Text != "-")
            {
                MessageBox.Show("Please uninstall VMT before install.\nインストールを続ける前に、VMTをアンインストールしてください", title, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                string driverPath_rel = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\..\vmt";
                string driverPath     = System.IO.Path.GetFullPath(driverPath_rel);
                Console.WriteLine(OpenVR.RuntimePath() + @"\bin\win64");
                Console.WriteLine(driverPath);

                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.WorkingDirectory = OpenVR.RuntimePath() + @"\bin\win64";
                process.StartInfo.FileName         = OpenVR.RuntimePath() + @"\bin\win64\vrpathreg.exe";
                process.StartInfo.Arguments        = "adddriver \"" + driverPath + "\"";
                process.StartInfo.UseShellExecute  = false;
                process.Start();
                process.WaitForExit();

                MessageBox.Show("OK (ExitCode=" + process.ExitCode + ")\nPlease restart SteamVR.", title);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, title);
                Close();
                return;
            }
        }
コード例 #2
0
        private async void UninstallButton(object sender, RoutedEventArgs e)
        {
            string driverPath_rel = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\..\vmt";
            string driverPath     = System.IO.Path.GetFullPath(driverPath_rel);

            if (installPath == "")
            {
                //インストールパスが受信できていない場合少し待つ
                await Task.Delay(2000);
            }

            if (installPath != "")
            {
                //場所がわかっている
                var res = MessageBox.Show("Uninstall VMT Driver?\nVMTドライバをアンインストールしますか?\n\n" + installPath, title, MessageBoxButton.OKCancel, MessageBoxImage.Question);
                if (res != MessageBoxResult.OK)
                {
                    return;
                }
                //現在のフォルダパスの代わりに、受信したパスでアンインストールを試す
                driverPath = installPath;
            }
            else
            {
                //場所不明だがとりあえず現在の場所としてアンインストールしようとするか確認する
                var res = MessageBox.Show("Other VMT Driver version detected.\nIn many cases, this driver located on different path.\nmanager can not uninstallation these.\nIf you want to remove currently installed VMT driver, press cancel and please use manager of drivers itself.\n\nPress OK, Try uninstallation anyway. (it will fail in many cases.)\n\n違うバージョンのVMTドライバを検出しました。\n多くの場合これは別のパスにあります。\n本Managerではアンインストールできません。\nアンインストールしたい場合は、キャンセルを押し、そのVMTドライバに付属のManagerを使用してください\n\nOKを押すと、とにかくアンインストールを試します。(多くの場合失敗します。)", title, MessageBoxButton.OKCancel, MessageBoxImage.Error);
                if (res != MessageBoxResult.OK)
                {
                    return;
                }
            }

            try
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.WorkingDirectory = OpenVR.RuntimePath() + @"\bin\win64";
                process.StartInfo.FileName         = OpenVR.RuntimePath() + @"\bin\win64\vrpathreg.exe";
                process.StartInfo.Arguments        = "removedriver \"" + driverPath + "\"";
                process.StartInfo.UseShellExecute  = false;
                process.Start();
                process.WaitForExit();

                MessageBox.Show("OK (ExitCode=" + process.ExitCode + ")\nPlease restart SteamVR.", title);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, title);
                Close();
                return;
            }
        }
コード例 #3
0
    public static async Task <string> UninstallVMT()
    {
        string driverPath_rel = @"C:\VirtualMotionTracker\vmt";
        string driverPath     = System.IO.Path.GetFullPath(driverPath_rel);

        server.enabled = true; //インストール情報を調べるために一時的に有効化

        await Task.Delay(1000);

        //インストールパスが受信できていない場合少し待つ
        if (string.IsNullOrEmpty(installPath))
        {
            await Task.Delay(2000);
        }

        server.enabled = false; //無効化


        if (string.IsNullOrEmpty(installPath) == false)
        {
            //場所がわかっている
            driverPath = installPath;
        }

        try
        {
            var runtimePath = OpenVR.RuntimePath();
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.WorkingDirectory = runtimePath + @"\bin\win64";
            process.StartInfo.FileName         = runtimePath + @"\bin\win64\vrpathreg.exe";
            process.StartInfo.Arguments        = "removedriver \"" + driverPath + "\"";
            process.StartInfo.UseShellExecute  = false;
            await Task.Run(() =>
            {
                process.Start();
                process.WaitForExit();
            });
        }
        catch (Exception ex)
        {
            return("Error:" + ex.Message + "\n" + ex.StackTrace);
        }
#if UNITY_EDITOR
        return("Restart skipped due to application running on editor.");
#else
        return(null);
#endif
    }
コード例 #4
0
        private void InstallButton(object sender, RoutedEventArgs e)
        {
            if (DriverVersion.Text != " - ")
            {
                //MessageBox.Show("Please uninstall VMT before install.\nインストールを続ける前に、VMTをアンインストールしてください", title, MessageBoxButton.OK, MessageBoxImage.Error);
                TopWarningMessage("Please uninstall VMT before install.\nインストールを続ける前に、VMTをアンインストールしてください", true);
                return;
            }

            try
            {
                string driverPath_rel = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\..\vmt";
                string driverPath     = System.IO.Path.GetFullPath(driverPath_rel);
                Console.WriteLine(OpenVR.RuntimePath() + @"\bin\win64");
                Console.WriteLine(driverPath);

                if (driverPath.Length > 100)
                {
                    MessageBox.Show("Path length over 100. it couldn't install.\nパスの長さが100を超えています。インストールできません。\n\n" + driverPath, title, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (driverPath.Contains("Program Files"))
                {
                    MessageBox.Show("Path contains \"Program Files\". it couldn't install.\nパスに\"Program Files\"が入っています。インストールできません。\n\n" + driverPath, title, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (driverPath.Contains(" "))
                {
                    MessageBox.Show("Path contains space. it couldn't install.\nパスにスペースが入っています。インストールできません。\n\n" + driverPath, title, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (!File.Exists(driverPath + @"\bin\win64\driver_vmt.dll"))
                {
                    MessageBox.Show("driver_vmt.dll not found. Do not break apart files. it couldn't install.\ndriver_vmt.dllが見つかりませんでした。ファイル構成をバラバラにしないでください。。インストールできません。\n\n" + driverPath, title, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                Encoding enc = Encoding.GetEncoding("us-ascii", new EncoderExceptionFallback(), new DecoderExceptionFallback());
                try
                {
                    enc.GetBytes(driverPath);
                }
                catch (EncoderFallbackException) {
                    MessageBox.Show("Path contains non-ascii (Japanese, Chinese, emoji, or other). it couldn't install.\nパスに非ASCII文字(日本語、中国語、絵文字、その他)が入っています。インストールできません。\n\n" + driverPath, title, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.WorkingDirectory = OpenVR.RuntimePath() + @"\bin\win64";
                process.StartInfo.FileName         = OpenVR.RuntimePath() + @"\bin\win64\vrpathreg.exe";
                process.StartInfo.Arguments        = "adddriver \"" + driverPath + "\"";
                process.StartInfo.UseShellExecute  = false;
                process.Start();
                process.WaitForExit();

                MessageBox.Show("OK (ExitCode=" + process.ExitCode + ")\nPlease restart SteamVR.", title);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, title);
                Close();
                return;
            }
        }