<commit_before>const lib = require("../lib.js");
const argv = require("../argv.js");

function WScriptShell() {
	this.environment = (x) => {
		if (x.toLowerCase() === "system")
			return (argument) => {
				const vars = {
					comspec: "%SystemRoot%\\system32\\cmd.exe",
					os: "Windows_NT",
					// Emulate a 32-bit environment for maximum compatibility
					processor_architecture: "x86",
				};

				argument = argument.toLowerCase();
				if (argument in vars) return vars[argument];
				lib.kill(`Unknown parameter ${argument} for WScriptShell.Environment.System`);
			};
		return `(Environment variable ${x})`;
	};
	this.specialfolders = (x) => `(Special folder ${x})`;
	this.createshortcut = () => ({});
	this.expandenvironmentstrings = (path) => {
		path = path.replace(/%COMPUTERNAME%/gi, "USER-PC");
		path = path.replace(/%PROCESSOR_REVISION%/gi, "0209");
		path = path.replace(/%PROGRAMDATA%/gi, "C:\\ProgramData");
		path = path.replace(/%TE?MP%/gi, "C:\\DOCUME~1\\User\\LOCALS~1\\Temp");
		path = path.replace(/%USERNAME%/gi, "User");
		path = path.replace(/%USERPROFILE%/gi, "C:\\Users\\User");
		path = path.replace(/%WINDIR%/gi, "C:\\WINDOWS");

		// %APPDATA% equals C:\Documents and Settings\{username}\Application Data on Windows XP,
		// but C:\Users\{username}\AppData\Roaming on Win Vista and above
		if (argv["windows-xp"])
			path = path.replace(/%APPDATA%/gi, "C:\\Documents and Settings\\User\\Application Data");
		else
			path = path.replace(/%APPDATA%/gi, "C:\\Users\\User\\AppData\\Roaming");

		if (/%\w+%/i.test(path)) {
			lib.warn("Possibly failed to expand environment strings in " + path);
		}

		return path;
	};
	this.exec = this.run = function(...args) {
		const command = args.join(" ");
		const filename = lib.getUUID();
		lib.info(`Executing ${lib.directory + filename} in the WScript shell`);
		lib.logSnippet(filename, {as: "WScript code"}, command);
		if (!argv["no-shell-error"])
			throw new Error("If you can read this, re-run box.js with the --no-shell-error flag.");
	};
	this._reg_entries = {
		"HKLM\\SOFTWARE\\MICROSOFT\\WINDOWS NT\\CURRENTVERSION\\CURRENTVERSION": "5.1",
		"HKLM\\SOFTWARE\\MICROSOFT\\WINDOWS NT\\CURRENTVERSION\\SYSTEMROOT": "C:\\WINDOWS",
		"HKLM\\SOFTWARE\\MICROSOFT\\WINDOWS\\CURRENTVERSION\\EXPLORER\\SHELL FOLDERS\\COMMON DOCUMENTS": "C:\\Users\\Public\\Documents",
	};
	this._normalize_reg_key = (key) => {
		key = key.toUpperCase().replace("HKEY_LOCAL_MACHINE", "HKLM");
		key = key.replace("HKEY_CLASSES_ROOT", "HKCR").replace("HKEY_USERS", "HKU");
		key = key.replace("HKEY_CURRENT_USER", "HKCU").replace("HKEY_CURRENT_CONFIG", "HKCC");
		return key;
	};
	this.regread = (key) => {<commit_msg>Fix library usage<commit_after>const lib = require("../lib.js");
const argv = require("../argv.js");

function WScriptShell() {
	this.environment = (x) => {
		if (x.toLowerCase() === "system")
			return (argument) => {
				const vars = {
					comspec: "%SystemRoot%\\system32\\cmd.exe",
					os: "Windows_NT",
					// Emulate a 32-bit environment for maximum compatibility
					processor_architecture: "x86",
				};

				argument = argument.toLowerCase();
				if (argument in vars) return vars[argument];
				lib.kill(`Unknown parameter ${argument} for WScriptShell.Environment.System`);
			};
		return `(Environment variable ${x})`;
	};
	this.specialfolders = (x) => `(Special folder ${x})`;
	this.createshortcut = () => ({});
	this.expandenvironmentstrings = (path) => {
		path = path.replace(/%COMPUTERNAME%/gi, "USER-PC");
		path = path.replace(/%PROCESSOR_REVISION%/gi, "0209");
		path = path.replace(/%PROGRAMDATA%/gi, "C:\\ProgramData");
		path = path.replace(/%TE?MP%/gi, "C:\\DOCUME~1\\User\\LOCALS~1\\Temp");
		path = path.replace(/%USERNAME%/gi, "User");
		path = path.replace(/%USERPROFILE%/gi, "C:\\Users\\User");
		path = path.replace(/%WINDIR%/gi, "C:\\WINDOWS");

		// %APPDATA% equals C:\Documents and Settings\{username}\Application Data on Windows XP,
		// but C:\Users\{username}\AppData\Roaming on Win Vista and above
		if (argv["windows-xp"])
			path = path.replace(/%APPDATA%/gi, "C:\\Documents and Settings\\User\\Application Data");
		else
			path = path.replace(/%APPDATA%/gi, "C:\\Users\\User\\AppData\\Roaming");

		if (/%\w+%/i.test(path)) {
			lib.warning("Possibly failed to expand environment strings in " + path);
		}

		return path;
	};
	this.exec = this.run = function(...args) {
		const command = args.join(" ");
		const filename = lib.getUUID();
		lib.info(`Executing ${lib.directory + filename} in the WScript shell`);
		lib.logSnippet(filename, {as: "WScript code"}, command);
		if (!argv["no-shell-error"])
			throw new Error("If you can read this, re-run box.js with the --no-shell-error flag.");
	};
	this._reg_entries = {
		"HKLM\\SOFTWARE\\MICROSOFT\\WINDOWS NT\\CURRENTVERSION\\CURRENTVERSION": "5.1",
		"HKLM\\SOFTWARE\\MICROSOFT\\WINDOWS NT\\CURRENTVERSION\\SYSTEMROOT": "C:\\WINDOWS",
		"HKLM\\SOFTWARE\\MICROSOFT\\WINDOWS\\CURRENTVERSION\\EXPLORER\\SHELL FOLDERS\\COMMON DOCUMENTS": "C:\\Users\\Public\\Documents",
	};
	this._normalize_reg_key = (key) => {
		key = key.toUpperCase().replace("HKEY_LOCAL_MACHINE", "HKLM");
		key = key.replace("HKEY_CLASSES_ROOT", "HKCR").replace("HKEY_USERS", "HKU");
		key = key.replace("HKEY_CURRENT_USER", "HKCU").replace("HKEY_CURRENT_CONFIG", "HKCC");
		return key;
	};
	this.regread = (key) => {
{'fraction_non_alphanumeric': 0.201156932263482, 'fraction_numerical': 0.005224855383467065, 'mean_word_length': 3.9129239230064163, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '628092', 'n_tokens_mistral': 2059, 'n_tokens_neox': 1874, 'n_words': 362}