Trying to read the installation path of the game (InstallLocation) from one section in the registry (SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 4000), write it to another section (SOFTWARE\WpfApp) in key (NewInstallPath), and then find the exe file with the game in the installation path of the game, and run
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
namespace wpfApp
{
/// \<summary\>
/// Interaction logic for MainWindow.xaml
/// \</summary\>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
using var localMachineRegistry = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
using var gmodAppRegistry = localMachineRegistry.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 4000", false);
string readInstallPath = gmodAppRegistry.GetValue("InstallLocation").ToString();
RegistryKey InstallPath = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\WpfApp", SetValue("NewInstallPath", readInstallPath)); //launcher partition path
}
}
}
As soon as I did not try to implement it, but even according to the documentation it comes out crooked. That value is recorded, but the game does not start, then nothing is recorded at all and does not start.
The way you're intended to run steam games is through steam itself.
Steam automatically updates the app etc.
There is a rungameid command line parameter which allows you to run a game ( somewhat ) directly.
"C:\Program Files (x86)\Steam\steam" steam://rungameid/281990
And... eventually as my login credentials install etc etc were stale...
Steam may be in C:\Program Files instead.
The nice-ish aspect of this is that you just need to check where steam is and know your game app id.
You can also run a game that isn't currently installed this way. There will of course be quite a delay as steam goes and gets everything for you.
I think some games are not so straight forward that they "just" have the one exe. Some have launchers ( ours does ).