Steam client Update control

What is this?
With this button you can easily disable (and re-enable) the auto-update functionality of the Steam client.

How it works?
You click the button and it tells you whether the Steam client update is currently enabled or disabled and offers you to toggle that state.

Please note that we're talking about inhibiting the Steam client updates. Game updates (for better or worse) are not affected by this.

What it does?
It autodetects Steam installation directory and creates the steam.cfg file there which contains setting BootStrapperInhibitAll=enable. This less-known method causes Steam to forgo its update check.

Download the button
Steam client Update control.dcf (5.9 KB)

(jscript code of the button for review)
function OnClick(clickData)
{
    // Setup ---------------------------------
    var config_filename = "steam.cfg";
    var config_key = "BootStrapperInhibitAll";
    // ---------------------------------------
    var DOpusFactory = DOpus.Create();
    while (DOpusFactory.SysInfo.FindProcess("steam.exe") != 0)
    {
        var retry = AskConfirmation("Steam is currently running, please Exit Steam from the tray.", "Retry");
        if (!retry) return;
    }
    
    var steamdir = getSteamDir();
    var config_fullpath = steamdir + "\\" + config_filename;
    var inhibit_update_parameter = "disable";

    if (DOpus.FSUtil.Exists(config_fullpath)) // If the steam.cfg already exists, read the current state.
    {
        DOpus.Output("Existing steam.cfg found");
        var fileContent = readFileContentAsString(config_fullpath);
        if (fileContent.split("\n").length == 1 && fileContent.split("=")[0] == config_key)
        {
            inhibit_update_parameter = fileContent.split("=")[1];
        }
        else
        {
            var proceed = AskConfirmation("Existing steam.cfg was found but it appears that it contains some custom values.\n\nIf you proceed, the entire file will be overwritten and your custom settings lost!", "Proceed anyway");
            if (!proceed) return;
        }
    }

    var bool_inhibit_update_parameter = inhibit_update_parameter != "enable";
    var predicate = (bool_inhibit_update_parameter) ? "allowed" : "blocked";
    var verb = (bool_inhibit_update_parameter) ? "Block updates" : "Allow updates";
    var new_value = (bool_inhibit_update_parameter) ? "enable" : "disable";

    var proceed = AskConfirmation("Steam client updates are currently " + predicate + ".", verb);
    if (proceed)
    {
        var stringToWrite = config_key + "=" + new_value;

        var OVERWRITE = true;
        var fso  = new ActiveXObject("Scripting.FileSystemObject");
        var fh = fso.CreateTextFile(config_fullpath, OVERWRITE);

        fh.Write(stringToWrite);
        fh.Close();

        DOpus.Output("Successfully written " + config_fullpath);
    }
}

// Custom functions
function getSteamDir()
{
    var key = 'HKEY_CURRENT_USER\\Software\\Valve\\Steam\\SteamPath';
    var wsh = new ActiveXObject("WScript.Shell");
    return wsh.RegRead(key);
}

function readFileContentAsString(filepath)
{
    var DOpusFactory = DOpus.Create();
    var blob = DOpus.FSutil.OpenFile(filepath).Read();
    return DOpusFactory.StringTools.Decode(blob, "utf-8");
}

function MsgBox(message)
{
    var dlg = DOpus.Dlg;
    dlg.message = message;
    dlg.icon = "error";
    dlg.buttons = "OK";
    dlg.Show();
}

function AskConfirmation(message, verb)
{
    var dlg = DOpus.Dlg;
    dlg.message = message;
    //dlg.icon = "question";
    dlg.buttons = verb + "|Cancel";
    return dlg.Show(); // from docs: If a dialog has more than one button then by definition the last (right-most) button is the "cancel" button and so this will return index 0.
}