-
-
Notifications
You must be signed in to change notification settings - Fork 119
Templated platform guide
Since 2022-01-30_00 (Version 5.0) there have been huge changes to the way the program works, including a massive update to the platforms supported. A templated platform system was added for easier management of platforms supported, and a lot of the existing account switchers were moved from hard code into this new format.
You can help improve and add platforms by editing the Platforms.json
file and pushing a commit. If you need to add extra functions and the rest, obviously include those changes as well. More details on editing the JSON file can be found in this Wiki article.
In the future, there should be some kind of plugin system. Developers can create .dlls to drop into a plugins folder. These are loaded, and referenced in the Platforms.json
file. Methods can be called before, during and after specific functions, such as swapping an account.
In the Platforms
object, there are multiple platform objects. The platform object's key is the program's name. For example "Escape from Tarkov".
Inside the Platform object, there are required keys and optional keys.
- Identifiers (Array of Strings): Unique (to each other and other platform's Identifiers) short names for the program. The first is the Primary Identifier, used for shortcuts and CLI interaction.
- ExeLocationDefault (String): The full path, including the program's EXE.
-
ExesToEnd (Array of Strings): The exe names of every process to kill/close when switching accounts. These can be processes or services. If it's a service you can use "
SERVICE:
" followed by the service name, for example, "SERVICE:Origin Web Helper Service
". Exes that are services will also be picked up and closed as normal. -
PathListToClear (Array of Strings): A full list of files, folders and folders with wildcards to clear. The same format as the Key in the
LoginFiles
object below.- This can be empty to not delete/remove anything when switching, or adding a new account.
- Use "SAME_AS_LOGIN_FILES" as the only string to use the keys from
LoginFiles
below.
-
LoginFiles (Object): Each key is the full path of a file, folder or path with a wildcard to swap when switching, or saving an account. Each value is the same location for the file/s in the
LoginCache\Username
folder (unless it has a variable, in which case it's absolute). Here are some examples of keys inLoginFiles
- File:
%AppData%\obs-studio\global.ini
- Folder:
%AppData%\\obs-studio\\basic
or%AppData%\\obs-studio\\basic\\*
- Ending with a
*
indicates a recursive copy -> All files and folders with their contents are included. - If this ends with a * it also means recursive delete. Every file, folder and folder specified will be deleted.
- Ending with a
- Wildcard: "Search terms" like:
%AppData%\discord\data_*
or%AppData%\discord\*.log
.- This is not recursive. Instead manually include
%AppData%\discord\*.dat
and%AppData%\discord\folder 1\*.dat
for example.
- This is not recursive. Instead manually include
- If files, registry entries or JSON keys don't appear on the users system, they will be stepped over and ignored. If EVERY file is absolutely required for a successful switch, set
AllFilesRequired
totrue
.
- File:
Each platform needs some way of verifying what user is currently logged in. This can be a username or email in a file (Use the REGEX option below), Hash of a file (FILE_MD5), a registry key (REGKEY) or the TcNo Account Switcher can randomly generate an ID and store it in a unique file (CREATE_ID_FILE). This last option has some extra steps below.
-
UniqueIdFile (String): The path of the file/registry key that stores the current logged-in account's unique identifier.
- If a registry key, set
UniqueIdMethod
to "REGKEY". Does not need to start with "REG:"- This should be added to
LoginFiles
as well, as: "REG:HKXX\\path:SubKeyName"- "REG:" indicates this "file" is a registry key.
- HKXX can be HKCR, HKCU, HKLM, HKCC (CurrentConfig), or HKPD (Performance Data).
- SubKeyName is used to read and write, and for now, its value is only treated as a string.
- This should be added to
- If a file (or folder of files to search - If a wildcard is used) it MUST be in the
LoginFiles
list. This way the program knows where to get this unique key, and where to store it. If this needs a wildcard, for example, "*.olc
", you can simply make sure it appears as such: "%ProgramData%\\*.olc
:ProgramData\\*.olc
" - The first file found matching this will be used. - If a JSON value, set
UniqueIDMethod
to "JSON_SELECT" to select an entire string. "JSON_SELECT_FIRST" to select the first element or "JSON_SELECT_LAST" for the last element. If either of the more specific latter, enter a delimiter immediately after, for example; "JSON_SELECT," to use a comma as a delimiter.- This should be added to
LoginFiles
as well, as: "JSON:FILEPATH::QUERYSTRING".- "JSON:" indicated this file is a JSON file, and a value is about to be found and returned. This can be either replaced with a few options in
LoginFiles
[Using"emails": "[email protected],[email protected]"
as an example]:-
JSON:
to just get a single value and clear it on account switch. Example result:[email protected],[email protected]
. -
JSON_SELECT_FIRST<delim>:
-<delim>
is the seperator to be used with the string value. For example, this is used with: - This is the delimiter. Example result:[email protected]
-
JSON_SELECT_LAST<delim>:
-<delim>
is the seperator to be used with the string value. For example, this is used with: - This is the delimiter. Example result:[email protected]
-
- "FILEPATH" is self-explanatory
- "QUERYSTRING" (notice the
::
before this) is used to find a specific element and value. Details about the query string can be found on Newtonsoft's website underSelectToken
andSelectToken with JSONPath
. The LINQ is not used with this parameter.
- "JSON:" indicated this file is a JSON file, and a value is about to be found and returned. This can be either replaced with a few options in
- This should be added to
- If a registry key, set
-
UniqueIdRegex (String): This is optional. If set, this is what will be used to get the unique ID from the
UniqueIdFile
mentioned above. This is a simple REGEX string. It will be used asRegex.Match(path, UniqueIdRegex)
. This supports 'variables' as well.- "EMAIL_REGEX" expands to regex to grab an email address from a file.
- For more details, see Globals.cs and search for "ExpandRegex".
-
UniqueIdMethod (String): The method used to get the unique ID. If
UniqueIdRegex
is used, this can be ignored. The methods include:-
CREATE_ID_FILE: Creates a unique ID file. Usually
UniqueIdFile
is set to "TcNoAccSwitcher-ID.instance". -
REGKEY: If the unique ID is stored in the Windows Registry - See
UniqueIdFile
above. -
FILE_MD5: Creates and uses a hash of the
UniqueIdFile
.
-
CREATE_ID_FILE: Creates a unique ID file. Usually
- ClearLoginCache (Bool): This is true by default. If this is set to false, when saving an account the existing account that is about to be moved in will simply add files to the folder, instead of replacing everything. With Discord, for example, the blob_storage folder has 1 file to start. Switch 1 time and you have 2, a second time and you have 3, and so on. This results in bloat, and extra files.
For file paths you can use environment variables you can set in PATH, or use default ones such as %AppData%
, %LocalAppData%
, or you can use custom ones that are enabled by the program such as:
-
%Platform_Folder%
: The folder that contains the main exe for the platform. This is eitherExeLocationDefault
or a path the user set when they were asked to locate the main exe. -
%TCNO_UserData
: The TcNo Account Switcher's main folder contains all the settings files, the LoginCache folder and more. Default is%AppData%\TcNo Account Switcher
-
%TCNO_AppData%
: The TcNo Account Switcher's install folder. I don't see any uses for this, but it is here if necessary.- If any LoginFiles file contains this, the program will check whether you can edit files in this folder when opening the platform, and restart as admin if required.
- These custom, self-explanatory ones have also been added:
%Documents%
,%Music%
,%Pictures%
,%Videos%
,%StartMenu%
. In C# as:Environment.SpecialFolder...
-
%StartMenuProgramData%
expands toC:\ProgramData\Microsoft\Windows\Start Menu\programs
, and%StartMenuAppData%
expands toC:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
just to make life simpler for those looking here.
While some of the options above are optional, depending on other keys' existence, these are completely optional.
- ExitBeforeInteract (Bool): Used when the program should be closed/killed before saving data files, etc.
- PeacefulExit (Bool): Closes the process's main window, instead of killing the process. Use when a program needs to save data after the first login, and only does so after being gracefully closed.
-
Extras (Object): Contains extra keys, listed below:
-
CachePaths (Array of strings): If included, create a "Clear Cache" button in the platform's settings. When clicked the TcNo Account Switcher will clear these folders/delete these files. This follows the same rules as
LoginFiles
. -
UsernameModalCopyText (String): If set this file's text will be read and copied to the users' clipboard when a newly created Copy button is clicked -> This appears in the username modal for saving or renaming accounts.
- This is, for example, used to copy JS to be pasted into the Discord console to grab not only the username but also the profile picture of the account. See Special Arguments below.
-
UserModalHintText (String): The language variable to be grabbed. This should be localised in the
Resources\*.yml
files. The text grabbed from language files is displayed as a toast description that pops up into the user's view when they click the Copy button. - ShortcutFolders (Array of strings): A list of folders to search for .lnk, .url and other shortcut files to include in the new Shortcut section and dropdown for launching games or other programs from the account switcher screen.
- ShortcutIgnore (String): If any files from ShortcutFolders above contains this string, then it is ignored. Useful for platforms that you would usually never launch the main program for.
- ShortcutIncludeMainExe (Bool): This is true if excluded. When this is set to false, there will NOT be a button to launch the platform's main EXE. Similar to ShortcutIgnore above.
- SearchStartMenuForIcon (Bool): When set to true, both AppData and ProgramData start menu folders will be searched for this platform's file safe name. If a matching file is found, its icon will be used for the start platform button, mentioned in ShortcutIncludeMainExe above. This is a recursive search, and can support the wildcards that Directory.GetFiles() supports. Useful for programs like Discord where an updater is called with arguments to start the platform - And said updater has no icon, or the wrong one. Common with Electron apps.
-
GetPathFromShortcutNamed (String): Enter the exact name of the shortcut in the Start Menu to get installed path from this if not in default path. Only uses
.lnk
(so don't include that), can not get path from Steam's.url
shortcuts, for example. Doesn't have to point to the EXACT exe we're looking for, just the same folder as it's located in. String can contain a|
to have multiple possible shortcut names, such as"OBS Studio (64bit)|OBS Studio"
. Both AppData and ProgramData start menu folders will be searched for this, as well as the top level of the Desktop (not folders on the desktop). - ProfilePicFromFile (String): File, directory or filepath with wildcards. "REG:" also supported. This file/these files will be searched for a profile picture filepath or URL. If it's a filepath: It will be used to copy an image. If it's a URL: It will be downloaded, and used as the profile image.
-
ProfilePicPath (String): If this is set, the ProfilePicFromFile will be considered a File name (Reference this in this string as
%FileName%
). For example:%Platform_Folder%\\cache\\avatars\\%FileName%.png
.- You can also use
%UniqueId%
to reference the account's unique ID. - While this can be used with other ProfilePicFromFile or ProfilePicRegex, you don't need to set them as well. Maybe you just need a folder path, where the uniqueId is used.
- You can use
%LARGEST%
to pick the largest file in a folder, or%LARGEST%.ext
to pick the largest file with.ext
type. This is currently only for ProfilePic. Example:imagefolder\\%UniqueId%\\%LARGEST%.png
.
- You can also use
- ProfilePicRegex (String): When used with the option above, this regex string (or regex string placeholder) will be used to search the file/s from ProfilePicFromFile. The first path to match fill be used.
-
BackupPaths (Object): Dictionary of folders or files, and destination folders (or file paths) to include in the backup - Example:
"%Platform_Folder%\\config": "config"
. Files are copied if they are listed, and will not be affected by options. There are 2 backup options. The first is backup, the second is backup everything. If you don't set the filters, there will only be 1 button (Backup everything). The second option ignores the next 2 optional filters: - BackupFileTypesInclude (List of String): A list of filetypes ('.' included) to INCLUDE in the first backup option. Use either this OR the next option (not both).
- BackupFileTypesIgnore (List of String): A list of filetypes ('.' included) to IGNORE in the first backup option. Use either this OR the previous option (not both).
- ClosingMethod (String): The method used to close the platform. Can be: Combined, Close or TaskKill. TaskKill doesn't work well with services and was previously the default. This requires service EXE's to be defined with "SERVICE:" before their name! Othwise if they are running as admin, it will force the user to use the account switcher in admin (Steam and steamservice.exe for example - It doesn't NEED to close to switch). Using Close will be more thorough (usually), but does require admin to end services. Combined is the best choice (and the default). It first tries to TaskKill, and then continues to try closing each of the remaining processes manually.
-
StartingMethod (String): The method used to start the platform. Can be: Default or Direct. The default uses the
runas.exe
program in the TcNo Account Switcher's install directory to start another process. This helps deal with UAC and other permission-related issues in Windows. This helps more reliably start processes in the right place, with the right permission levels. - RegDeleteOnClear (Bool): When set to True registry entries listed as to be cleared on account switch will instead be deleted. This way when programs react unexpectedly to empty registry keys, they may react better to non-existent ones and are recreated instead of causing a blank screen or outright crash.
-
AllFilesRequired (Bool): When set to
true
, all files, JSON keys and registry keys inLoginFiles
are required to be found and copied for a successful account switch. By default this value isfalse
, to account for minor platform changes like a launcher not requiring a specific file, or for certain versions for different games like the Rockstar Launcher where specific files are missing for specific games, but the rest are present. This just hides the Toast that pops up, and continues switching accounts. Missed files are logged.
-
CachePaths (Array of strings): If included, create a "Clear Cache" button in the platform's settings. When clicked the TcNo Account Switcher will clear these folders/delete these files. This follows the same rules as
This is extra information optionally inputted by the user into the Username box when saving, or renaming an account. This can be used to cause multiple actions to happen. Currently, it only lets the user enter a path to a local file, or URL to download a profile picture that is linked to this account.
Usernames that want to use Special Arguments must be laid out as such: USERNAME:{JSON OBJECT}. JSON OBJECT is a string JSON object. Keys may include:
- image: A URL or file path to where the program can find an image to download or copy. This may include the environment variables mentioned above.
Find more info in BasicSwitcherFuncs.cs and search for "ProcessSpecialAccName".
All trademarks and materials are the property of their respective owners and their licensors. This project is not affiliated with any companies referenced. This is not "Official" software or related to any companies mentioned. All it does is let you move your files around on your computer the same way you can. The use of names, icons and trademarks does not indicate endorsement of the trademark holder by this project or its creators, nor vice versa. They are only used to visually indicate which programs this project interacts with easily to the end-user.
By enabling optional features that scrape the web for publically available information (such as limited game/profile statistics and other data), you understand and accept full responsibility for doing so on your own volition. If you appreciate accurate information, support the services providing it directly. The information collected is incredibly limited and is no replacement or competitor for sites scraped.
I am not responsible for the contents of external links. For the rest of the disclaimer, refer to the License (GNU General Public License v3.0) file: https://github.com/TcNobo/TcNo-Acc-Switcher/blob/master/LICENSE - See sections like 15, 16 and 17, as well as GitHub's 'simplification' at the top of the above website.