void GetCraftbotPath() { // Get Steam location from registry SteamInstallPath = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Valve\\Steam", "SteamPath", "NOT FOUND"); Debug.Print("SteamPath: \"{0}\"", SteamInstallPath); if (!Directory.Exists(SteamInstallPath)) { SteamError(); } // Turning VDF into JSON, because it's not possible to select the "1" key with VDF // Unique case worth fixing: // TODO: Fix exception when installation on external drive is disconnected dynamic libraryfoldersjson = new VProperty(); try { libraryfoldersjson = VdfConvert.Deserialize(File.ReadAllText(SteamInstallPath + "\\steamapps\\libraryfolders.vdf")).Value.ToJson(); } catch { SteamError(); } if (File.Exists(SteamInstallPath + "\\steamapps\\appmanifest_387990.acf")) { CraftingPath = SteamInstallPath + "\\steamapps\\common\\Scrap Mechanic\\Survival\\CraftingRecipes\\"; } else { CraftingPath = libraryfoldersjson.Value <String>("1") + "\\steamapps\\common\\Scrap Mechanic\\Survival\\CraftingRecipes\\"; } Debug.Print("Registered steam: " + SteamInstallPath); Debug.Print("Game Path: " + CraftingPath); }
public string GetRelativeInstallDirectory() { var manifest = VdfConvert.Deserialize(_manifestFileReader.ReadToEnd()); var children = manifest.Value.Children <VProperty>(); return(children.FirstOrDefault(x => x.Key == "installdir")?.Value?.ToString()); }
private void Parse(string path) { VObject vObject = (VObject)VdfConvert.Deserialize(File.ReadAllText(path).Replace(@"\", @"\\")).Value; DepotId = int.Parse(vObject["DepotID"].ToString()); ContentRoot = vObject["ContentRoot"].ToString(); foreach (VProperty child in vObject.Children()) { switch (child.Key) { case "FileMapping": VObject mapping = (VObject)child.Value; FileMappings.Add(new FileMapping { LocalPath = mapping["LocalPath"].ToString(), DepotPath = mapping["DepotPath"].ToString(), Recursive = int.Parse(mapping["recursive"].ToString()) }); break; case "FileExclusion": FileExclusions.Add(new FileExclusion(child.Value.ToString())); break; default: continue; } } }
public static IEnumerable <LoginUsers> GetLoginUsers() { dynamic volvo = VdfConvert.Deserialize(GetLoginUsersConfig()); VToken v2 = volvo.Value; return(v2.Children().Select(child => new LoginUsers(child)).Where(user => user.RememberPassword).ToList()); }
private static IObservable <IInstall> FindSteamInstall() { return(Observable .Create <SteamInstall>(obs => { var steamDirectory = "C:/Program Files (x86)/Steam"; if (!Directory.Exists(steamDirectory)) { throw new Exception("Unable to find steam install"); } // Find all game libraries steam knows about. var libraryFoldersVdfPath = "C:/Program Files (x86)/Steam/steamapps/libraryfolders.vdf"; var allLibraryFolders = new List <string> { steamDirectory }; if (File.Exists(libraryFoldersVdfPath)) { var libraries = VdfConvert.Deserialize(File.ReadAllText(libraryFoldersVdfPath)); if (libraries.Key == "LibraryFolders") { foreach (var item in libraries.Value.Where(v => v.Type == VTokenType.Property)) { var prop = item as VProperty; var value = prop.Value as VValue; if (Directory.Exists(value.Value as string)) { allLibraryFolders.Add(value.Value as string); } } } } // Check for SMNCs APPID folder in all the linstall directories foreach (var library in allLibraryFolders) { var steamapps = Path.Combine(library, "steamapps"); foreach (var file in Directory.GetFiles(steamapps, "*.acf")) { dynamic acf = VdfConvert.Deserialize(File.ReadAllText(file)); VValue appid = acf.Value.appid; if (appid.Value as string == "104700") { VValue installdir = acf.Value.installdir; obs.OnNext(new SteamInstall(Path.Combine(steamapps, "common", installdir.Value as string))); obs.OnCompleted(); return Disposable.Empty; } } } obs.OnError(new DirectoryNotFoundException("Unable to find a steam install of SMNC")); return Disposable.Empty; })); }
/// <summary> /// Gets the library folders in this Steam installation. /// </summary> /// <returns>Returns an <see cref="IEnumerable{T}"/> of <see cref="DirectoryInfo"/> instances.</returns> public async Task <IEnumerable <DirectoryInfo> > GetLibraryFoldersAsync() { if (!this.IsInstalled) { return(Array.Empty <DirectoryInfo>()); } List <DirectoryInfo> libraryFolders = new List <DirectoryInfo> { // steam install directory is the default library folder this.InstallDirectory }; string vdfPath = Path.Combine(this.InstallDirectory.ToString(), @"steamapps", @"libraryfolders.vdf"); using (StreamReader reader = new StreamReader(Path.GetFullPath(vdfPath))) { string contents = await reader.ReadToEndAsync().ConfigureAwait(false); JToken json = VdfConvert.Deserialize(contents).Value.ToJson(); libraryFolders.AddRange(JsonHelpers.IterateStringKeys(json) .Select(s => new DirectoryInfo(s))); } return(libraryFolders); }
public static void VdfNetDeserializeIterations(string vdf, int numIterations) { for (int index = 0; index < numIterations; index++) { VdfConvert.Deserialize(vdf); } }
private VProperty GetGameInfo() { var fileText = File.ReadAllText(_path, Windows1252); var info = EnableFormatting ? VdfConvert.Deserialize(fileText, VdfSerializerSettings.Common) : VdfConvert.Deserialize(fileText, VdfSerializerSettings.Default); return(info); }
public Dictionary <string, SteamUserInfo> get() { FileStream fs = File.OpenRead(Path); StringBuilder sb = new StringBuilder(); int code = 0; do { byte[] bt = new byte[fs.Length > 1024 ? 1024 : fs.Length]; code = fs.Read(bt, 0, bt.Length); sb.Append(UTF8Encoding.UTF8.GetString(bt)); } while (code == 1024); fs.Close(); VProperty v = VdfConvert.Deserialize(sb.ToString()); VToken[] keys = v.Value.ToArray <VToken>(); Dictionary <string, SteamUserInfo> list = new Dictionary <string, SteamUserInfo>(); foreach (VToken vt in keys) { dynamic data = vt; SteamUserInfo user = new SteamUserInfo(); user.user = data.Value.AccountName.ToString(); user.id64 = data.Key; user.name = data.Value.PersonaName.ToString(); list.Add(data.Key, user); } return(list); }
public static List <string> FindSteamLibraries(string steam) { dynamic vdf = VdfConvert.Deserialize(File.ReadAllText(string.Join(Path.DirectorySeparatorChar, new List <string> { steam, "config", "config.vdf" }))); List <string> libraries = new List <string>(); if (Directory.Exists(string.Join(Path.DirectorySeparatorChar, new List <string> { steam, "steamapps" }))) { libraries.Add(string.Join(Path.DirectorySeparatorChar, new List <string> { steam, "steamapps" })); } try { foreach (VProperty child in ((VObject)vdf.Value.Software.valve.steam).Children()) { if (child.Key.StartsWith("BaseInstallFolder_")) { libraries.Add(string.Join(Path.DirectorySeparatorChar, new List <string> { child.Value.ToString(), "steamapps" })); } } } catch (Exception) { return(null); } return(libraries); }
private void load() { String strSteamInstallPath = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Valve\\Steam").GetValue("InstallPath").ToString(); Console.WriteLine(strSteamInstallPath); VProperty volvo = VdfConvert.Deserialize(File.ReadAllText(strSteamInstallPath + "\\config\\loginusers.vdf")); foreach (VToken vt in volvo.Value.ToList()) { dynamic user = VdfConvert.Deserialize(vt.ToString()); Int64 steamId = Convert.ToInt64(user.Key); String accountName = user.Value.AccountName.ToString(); String personalName = user.Value.PersonaName.ToString(); Console.WriteLine(accountName); Image picture; try { picture = Image.FromFile(strSteamInstallPath + "\\config\\avatarcache\\" + steamId + ".png"); } catch (FileNotFoundException E) { picture = Easy_switch.Properties.Resources.questionPicture; } flPanel.Controls.Add(createPanel(picture, accountName, personalName)); flPanel.Update(); flPanel.Show(); } }
private void FindSteamDirectories() { if (File.Exists(Steam.MainSteamDir + "/steamapps/libraryfolders.vdf")) { dynamic library = VdfConvert.Deserialize(File.ReadAllText(Steam.MainSteamDir + "/steamapps/libraryfolders.vdf")).ToJson(); bool addingDirectory = true; int directoryCount = 1; Steam.AdditionalSteamDirectories.Clear(); while (addingDirectory) { if (library.Value[directoryCount.ToString()] != null) { Steam.AdditionalSteamDirectories.Add(library.Value[directoryCount.ToString()].ToString()); directoryCount++; } else { addingDirectory = false; } } richTextBoxAdditionalSteamDirectory.Lines = Steam.AdditionalSteamDirectories.ToArray(); } CheckGamesInstalled(); }
public static string GetSteamIdFromConfig(string userName) { dynamic steamId = null; try { string steamPath = new IniFile(SAMSettings.FILE_NAME).Read(SAMSettings.STEAM_PATH, SAMSettings.SECTION_STEAM); // Attempt to find Steam Id from steam config. dynamic config = VdfConvert.Deserialize(File.ReadAllText(steamPath + "config\\config.vdf")); dynamic accounts = config.Value.Software.Valve.Steam.Accounts; VObject accountsObj = accounts; VToken value; accountsObj.TryGetValue(userName, out value); dynamic user = value; VValue userId = user.SteamID; steamId = userId.Value.ToString(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(Convert.ToString(steamId)); }
public static ConfigSteamData GetSteamConfig() => TryOrDefault(() => { var result = new ConfigSteamData(); var libraryPaths = new List <string>(); var steamPath = new DirectoryInfo(GetSteamData().SteamPath).FullName; var configPath = Path.Combine(steamPath, "config", "config.vdf"); libraryPaths.Add(Path.Combine(steamPath, "steamapps")); try { dynamic configObject = VdfConvert.Deserialize(File.ReadAllText(configPath)).Value; dynamic valve; try { valve = configObject.Software.Valve; } catch { valve = configObject.Software.valve; } var configLibraryPaths = ((VObject)valve.Steam) .Children() .Where(item => item.Key.StartsWith("BaseInstallFolder")) .Select(item => item.Value.ToString()) .Select(line => new DirectoryInfo(line).FullName) .Select(line => Path.Combine(line, "steamapps")); libraryPaths.AddRange(configLibraryPaths); } catch { } result.SteamLibraryFolders = libraryPaths.ToArray(); return(result); });
public List <string> GetSteamLibraries(string steamInstallationPath) { List <string> libraryDirectories = new List <string> { System.IO.Path.Combine(steamInstallationPath, "steamapps") }; string libraryVdfPath = System.IO.Path.Combine(steamInstallationPath, "steamapps", "libraryfolders.vdf"); dynamic vdf = VdfConvert.Deserialize(File.ReadAllText(libraryVdfPath)); for (int i = 1; true; i++) { string libraryIndex = i.ToString(); var libraryPath = vdf.Value[libraryIndex]; if (libraryPath != null) { string libraryAppsPath = System.IO.Path.Combine(libraryPath.ToString(), "steamapps"); logger.Info("Found Steam library: " + libraryAppsPath); if (!Directory.Exists(libraryAppsPath)) { logger.Info("Steam library doesn't exist: " + libraryAppsPath); continue; } libraryDirectories.Add(libraryAppsPath); } else { break; } } return(libraryDirectories); }
private void LoadSteamConfig() { Logger.LogInformation("Loading Steam system configuration."); var steamKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam"); if (steamKey == null) { Logger.LogError("Steam could not be detected from the registry."); return; } var installDir = (string)steamKey.GetValue("SteamPath"); Logger.LogInformation($"Found Steam at {installDir}"); Cache.LibraryPaths.Add(Path.Combine(installDir, @"steamapps\common")); try { _configVdf = VdfConvert.Deserialize(File.ReadAllText($@"{installDir}\config\config.vdf")); } catch (Exception e) { Logger.LogError(e, "Encountered an exception while reading the VDF. Steam configuration will not be loaded."); return; } Logger.LogInformation("Steam configuration loaded successfully."); }
/// <summary> /// Attempts to find a Steam game by its app ID across all Steam libraries. /// </summary> /// <param name="appId">The app ID of the sought game.</param> /// <returns>The path to the game, or null if it can't be found.</returns> public static string FindGame(int appId) { var appManifestRegex = new Regex(@"^appmanifest_(\d+).acf$"); foreach (var library in GetLibraries()) { // Look for appmanifest_###.acf files in the library's steamapps folder var steamapps = $"{library}\\steamapps\\"; foreach (var filePath in Directory.GetFiles(steamapps)) { var fileName = Path.GetFileName(filePath); var match = appManifestRegex.Match(fileName); if (match.Success) { // This is an appmanifest - find its ID var thisId = int.Parse(match.Groups[1].Value); if (appId == thisId) { // This is the app we were looking for - find the installation path var configFileText = File.ReadAllText(filePath); dynamic config = VdfConvert.Deserialize(configFileText); var installFolder = config.Value.installdir.Value; return($"{library}\\steamapps\\common\\{installFolder}"); } } } } return(null); }
/// <summary> /// Attempts to locate all the steam install folders from the steam VDF config file. /// Note: This does NOT include the actual steam install folder. /// /// The result of this operation should be appended along with the "{steamFolder}\steamapps\steamapps" folder. /// </summary> /// <param name="vdf"></param> /// <returns></returns> public static List <string> ExtractSteamLibraryPaths(string vdf) { List <string> paths = new List <string>(); if (File.Exists(vdf)) { dynamic config = VdfConvert.Deserialize(File.ReadAllText(vdf)); var root = config.Value; for (int i = 0; i < 8; i++) { try { paths.Add(root[$"{i}"].path.ToString()); } catch (KeyNotFoundException) { Logger.Debug($"Key #{i} not found, stopping parse of steam config"); return(paths); } catch (RuntimeBinderException) { Logger.Debug($"Key #{i} not found, stopping parse of steam config"); return(paths); } } } return(paths); }
public void CommentsDeserializeCorrectly() { const string vdf = @" // Comment type A (at the start of the file) ""root"" { // Comment type B (as a child to an object) key1 ""value1"" ""key2"" // Comment type C (to the right of a property name) { ""key3"" ""value3"" // Comment type D (to the right of a property value) } } // Comment type E (at the end of the file) "; VProperty result = VdfConvert.Deserialize(vdf); VProperty expected = new VProperty("root", new VObject { VValue.CreateComment(" Comment type B (as a child to an object)"), new VProperty("key1", new VValue("value1")), new VProperty("key2", new VObject { new VProperty("key3", new VValue("value3")), VValue.CreateComment(" Comment type D (to the right of a property value)"), }), }); Assert.True(VToken.DeepEquals(result, expected)); }
private void ParseVDFLibraries(string libraryFile, ref List <string> directories) { try { VProperty library = VdfConvert.Deserialize(File.ReadAllText(libraryFile)); foreach (var child in library?.Value?.Children()) { VProperty prop = child as VProperty; if (prop == null) { Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries failed to convert entity to VProperty: {child}"); continue; } // Folders have a numeric value if (!Int32.TryParse(prop.Key, out _)) { continue; } string path = string.Empty; if (prop.Value.Type == VTokenType.Value) { path = prop.Value?.ToString(); if (String.IsNullOrEmpty(path) || !Directory.Exists(path)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries (Old Format) failed to locate path: {prop}"); continue; } } else if (prop.Value.Type == VTokenType.Object) { path = prop.Value?["path"]?.ToString(); if (string.IsNullOrEmpty(path)) { Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries failed to locate path: {prop}"); continue; } string mounted = prop.Value?["mounted"]?.ToString() ?? "1"; if (mounted != "1") { Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries skipping unmounted folder: {path}"); continue; } } else { Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries invalid property type: {prop.Value.Type} for {prop}"); continue; } directories.Add(Path.Combine(path, STEAM_APPS_DIR)); } } catch (Exception ex) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"{this.GetType()} ParseVDFLibraries Exception: {ex}"); } }
public static string[] GetSteamLibraryPaths() { string[] libraryPaths = Array.Empty <string>(); using (RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))// Doesn't work in 32 bit mode without this { using (RegistryKey steamKey = hklm?.OpenSubKey(STEAM_PATH_KEY)) { string path = (string)steamKey?.GetValue("InstallPath", string.Empty); if (path != null && path.Length > 0) { string configPath = Path.Combine(path, STEAM_CONFIG_PATH); if (File.Exists(configPath)) { VProperty v = VdfConvert.Deserialize(File.ReadAllText(configPath)); VToken ics = v?.Value; VToken soft = ics?["Software"]; VToken valve = soft?["Valve"]; VObject steamSettings = valve?["Steam"] as VObject; VProperty[] settings = steamSettings?.Children <VProperty>()?.ToArray(); if (settings != null) { libraryPaths = settings.Where(p => p.Key.StartsWith("BaseInstallFolder")) .Select(p => p.Value.ToString()).ToArray(); } } } } } return(libraryPaths); }
public List <GameRom> GetSteamGame(Emulator emu) { string steamfolder; var key64 = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam"; var key32 = @"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam"; if (Environment.Is64BitOperatingSystem) { steamfolder = (string)Microsoft.Win32.Registry.GetValue(key64, "InstallPath", string.Empty); } else { steamfolder = (string)Microsoft.Win32.Registry.GetValue(key32, "InstallPath", string.Empty); } if (steamfolder != null) { List <string> foldersTosearch = new List <string>(); foldersTosearch.Add(Path.Combine(steamfolder, "steamapps")); VProperty volvo = VdfConvert.Deserialize(File.ReadAllText(Path.Combine(steamfolder, "steamapps", "libraryfolders.vdf"))); var childs = volvo.Value.Children(); foreach (var child in childs) { var childKV = (VProperty)child; var childValueKV = childKV.Value; var pathchildKV = childValueKV.FirstOrDefault(); if (pathchildKV != null) { //if (Directory.Exists(((VProperty)child).Value.ToString())) if (Directory.Exists(((VProperty)pathchildKV).Value.ToString())) { foldersTosearch.Add(Path.Combine(((VProperty)pathchildKV).Value.ToString(), "steamapps")); } } } List <GameRom> gamesfind = new List <GameRom>(); List <String> appmanifestfiles = new List <string>(); foreach (string foldertoSeek in foldersTosearch) { appmanifestfiles.AddRange(Directory.GetFiles(foldertoSeek, "appmanifest_*.acf").ToList()); } foreach (var file in appmanifestfiles) { dynamic appfile = VdfConvert.Deserialize(File.ReadAllText(file)); GameRom game = new GameRom(); game.EmulatorID = emu.EmulatorID; game.SteamID = int.Parse(appfile.Value.appid.Value); game.Name = appfile.Value.name.Value; gamesfind.Add(game); } return(gamesfind); } else { return(null); } }
public Template GetGameTemplate() { var manifest = VdfConvert.Deserialize(_manifestFileReader.ReadToEnd()); var dictionary = manifest.Value.Children <VProperty>()? .ToDictionary(x => x.Key, x => x.Value); return(CreateGameTemplate(dictionary)); }
private string FindProtonAppData() { string steamApps; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { steamApps = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".steam", "steam", "steamapps"); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { steamApps = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Application Support", "Steam", "steamapps"); } else { return(null); } if (!Directory.Exists(steamApps)) { return(null); } var libraries = new List <string> { steamApps, }; var vdf = Path.Combine(steamApps, "libraryfolders.vdf"); if (File.Exists(vdf)) { var libraryFolders = VdfConvert.Deserialize(File.ReadAllText(vdf)); foreach (var libraryFolder in libraryFolders.Value.Children <VProperty>()) { if (!int.TryParse(libraryFolder.Key, out _)) { continue; } libraries.Add(Path.Combine(libraryFolder.Value.Value <string>(), "steamapps")); } } foreach (var library in libraries) { var path = Path.Combine(library, "compatdata", AppId.ToString(), "pfx", "drive_c", "users", "steamuser", "AppData", "LocalLow"); if (Directory.Exists(path)) { return(path); } } return(null); }
static void ModMountCfg(string gmod, string cstrike) { VProperty prop = VdfConvert.Deserialize(File.ReadAllText(string.Join(Path.DirectorySeparatorChar, new List <string> { gmod, "garrysmod", "cfg", "mount.cfg" }))); prop.Value["cstrike"] = new VValue(cstrike); File.WriteAllText(string.Join(Path.DirectorySeparatorChar, new List <string> { gmod, "garrysmod", "cfg", "mount.cfg" }), VdfConvert.Serialize(prop)); }
public void GrabTexturesFromMaterials() { VProperty currentVmt = VdfConvert.Deserialize(File.ReadAllText("graygrid.vmt")); foreach (VToken token in currentVmt.Value) { Console.WriteLine(token.Value <VProperty>().Key); // Check if the value of this field is a texture in the VPK } }
private void Parse(string path) { VObject vObject = (VObject)VdfConvert.Deserialize(File.ReadAllText(path).Replace(@"\", @"\\")).Value; AppId = int.Parse(vObject["appid"].ToString()); BuildDescription = vObject["desc"].ToString(); BuildOutput = vObject["buildoutput"].ToString(); ContentRoot = vObject["contentroot"].ToString(); SetLive = vObject["setlive"].ToString(); Preview = vObject["preview"].ToString() == "1"; Local = vObject["local"].ToString(); }
public static IEnumerable <User2Json.SteamLoginUsers> GetLoginUsers() { if (SteamPath.SteamLocation == null) { SteamPath.Init(); } dynamic volvo = VdfConvert.Deserialize(File.ReadAllText(SteamPath.SteamLocation + @"\config\loginusers.vdf")); VToken v2 = volvo.Value; return(v2.Children().Select(child => new SteamLoginUsers((VProperty)child)).OrderByDescending(user => user.LastLoginTime).ToList()); }
/// <summary> /// Gets the games folder path. /// </summary> public static IEnumerable <string> GetGamesFolderPaths() { string SteamPath = SteamHelper.GetSteamAppsPath(); string LibraryPath = SteamHelper.GetLibraryPath(); string LibraryFile = File.ReadAllText(LibraryPath); if (string.IsNullOrEmpty(LibraryFile) == false) { VProperty Library = VdfConvert.Deserialize(LibraryFile); JProperty Json = Library.ToJson(); if (Json.Value["1"] != null) { string GamesPath = Json.Value["1"].ToObject <string>(); if (string.IsNullOrEmpty(GamesPath) == false) { if (string.IsNullOrEmpty(GamesPath) == false) { string CommonPath = Path.Combine(GamesPath, "steamapps\\common\\"); if (string.IsNullOrEmpty(CommonPath) == false) { yield return(CommonPath); } else { Log.Warning(typeof(SteamHelper), "CommonPath is empty."); } } else { Log.Warning(typeof(SteamHelper), "GamesPath is empty."); } } else { Log.Warning(typeof(SteamHelper), "GamesPath property is empty."); } } else { Log.Warning(typeof(SteamHelper), "LibraryFolders property is empty."); } } else { Log.Error(typeof(SteamHelper), "Empty ?"); } yield return(Path.Combine(SteamPath, "common")); }
/// <summary> /// Uses the technique from TcNo Account Switcher to change the loginUsers.vdf and /// some registry values so on next start steam is starting with the defined user /// only works if the user already logged in once with this account and chose "remember password"! /// </summary> /// <param name="selectedAccount">the account to start with</param> public void startCachedAccount(SteamAccount selectedAccount) { _steamInstallation.KillSteam(); dynamic loginUsersVdf = VdfConvert.Deserialize(File.ReadAllText(loginUsersVDFPath)); try { foreach (var account in loginUsersVdf.Value) { if (account.Key.ToString() == selectedAccount.SteamId) { account.Value.MostRecent.Value = "1"; if (account.Value.RememberPassword.Value == "0") { // Steam does not remember this accounts password! if (!string.IsNullOrEmpty(selectedAccount.Password)) { // If the user has a password, we use that to log in the old way resetActiveAccount(); _steamInstallation.StartSteamAccount(selectedAccount); } else { // Else we notify the user and let him log in MessageBox.Show( "This account does not have a password associated with it and can only be started if it has already logged in once and 'Remember Password' has been checked. Log in and select 'Remember Password' now or add a password in SteamAccountSwitcher.", "Cannot start with account", MessageBoxButton.OK, MessageBoxImage.Exclamation); break; } } } else { account.Value.MostRecent.Value = "0"; } } //MessageBox.Show(loginUsersVdf.ToString()); File.WriteAllText(loginUsersVDFPath, loginUsersVdf.ToString()); using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Valve\Steam")) { key.SetValue("AutoLoginUser", selectedAccount.AccountName); key.SetValue("RememberPassword", 1); } _steamInstallation.Start(); } catch (Exception e) { MessageBox.Show(e.Message); } }