Added context menu for VSCODE

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Answer
jorico
Messages: 27
Registration: August 11, 2022 - 4:42 PM
Location: NIORT

February 12, 2025 - 12:59

Hello TrankilIT team,

I modified the tis-vscode package to add VScode to the Windows context menu:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
import json


def install():
    bin_name = glob.glob("VSCodeSetup-*.exe")[0]
    if control.architecture == "x64":
        app_uninstallkey = "{EA457B21-F73E-494C-ACAB-524FDE069978}_is1"
    else:
        app_uninstallkey = "{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1"

    install_exe_if_needed(
        bin_name,
        silentflags='/verysilent /mergetasks="!runcode,addcontextmenufiles,addcontextmenufolders,associatewithfiles,addtopath"',
        key=app_uninstallkey,
        min_version=control.get_software_version(),
        timeout=600,
    )

    # Adding Firewall Rules
    app_name = "Visual Studio Code"
    app_path = makepath(installed_softwares(uninstallkey=app_uninstallkey)[0]["install_location"], "code.exe")
    run_powershell(f'Remove-NetFirewallRule -DisplayName "{app_name}" -ErrorAction SilentlyContinue', accept_returncodes=[0, 1, 3010])
    run_powershell(
        f'New-NetFirewallRule -DisplayName "{app_name}" -Group "{app_name}" -Program "{app_path}" -Action Allow -Direction Inbound -Enabled True'
    )


def session_setup():
    print("Disabling: Telemetry, automatic updates, surveys")

    # Configuration procedure: https://supunkavinda.blog/vscode-editing-settings-json
    # C:\Users\username\AppData\Roaming\Code\User\settings.json

    # Initializing variables
    user_conf_dir = makepath(user_appdata, "Code", "User")
    user_conf_file = makepath(user_conf_dir, "settings.json")
    user_conf_content = r"""{
    "update.mode": "none",
    "update.enableWindowsBackgroundUpdates": false,
    "update.showReleaseNotes": false,
    "telemetry.telemetryLevel": "off",
    "typescript.surveys.enabled": false,
    "extensions.autoCheckUpdates": false,
    "extensions.autoUpdate": false
}"""

    user_conf_data = json.loads(user_conf_content)
    if not isdir(user_conf_dir):
        mkdirs(user_conf_dir)
    if not isfile(user_conf_file):
        print("Creating: settings.json in: %s" % user_conf_dir)
        json_write_file(user_conf_file, user_conf_data)
    else:
        new_user_conf_data = json_load_file(user_conf_file)
        new_user_conf_data.update(user_conf_data)
        print("Updating: settings.json in: %s" % user_conf_dir)
        json_write_file(user_conf_file, new_user_conf_data)
I'm uploading my version of the package in case it helps :D
WAPT Enterprise 2.5.5.15697
Server = Debian 11 Bullseye
Console = Windows Server 2019
--------------------------------------------------------------------------

Johan
User avatar
t.heroult
Messages: 307
Registration: December 8, 2020 - 10:13 AM

February 18, 2025 - 09:26

Cool, thanks for sharing!
Server: WAPT Enterprise 2.6.1.17786 on Debian
Consoles: Windows 10 & 11
Infrastructure: Windows

Did you know? When parrotfish undergo smoltification, their osmoregulation mechanism is reversed!
Answer