Skip to content

Instantly share code, notes, and snippets.

@MarkTiedemann
Created February 15, 2025 20:56
Show Gist options
  • Save MarkTiedemann/371f1642d6b7afc768beb576badf1343 to your computer and use it in GitHub Desktop.
Save MarkTiedemann/371f1642d6b7afc768beb576badf1343 to your computer and use it in GitHub Desktop.
/** Provides access to root object for the Windows Script Host object model.
* @see https://www.vbsedit.com/html/4dc0e2db-3234-4383-afba-147154041dfd.asp */
interface WScript {
/** Returns the full path of the currently running script.
* @see https://www.vbsedit.com/html/00f4fa13-345d-492f-b879-4b34160f8cc1.asp */
readonly ScriptFullName: string;
}
declare var WScript: WScript;
/** The ActiveXObject Object enables and returns a reference to an automation object.
* @see http://udn.realityripple.com/docs/Archive/Web/JavaScript/Microsoft_Extensions/ActiveXObject */
interface ActiveXObject {
new (ServernameTypename: "WScript.Shell"): WshShell;
new (ServernameTypename: "Scripting.FileSystemObject"): FileSystemObject;
}
declare var ActiveXObject: ActiveXObject;
/** Allows you to create a shortcut programmatically.
* @see https://www.vbsedit.com/html/5ce04e4b-871a-4378-a192-caa644bd9c55.asp */
interface WshShortcut {
/** The path to the shortcut's executable.
* @see https://www.vbsedit.com/html/05736c92-ee7c-4614-bd28-fb66e188e7c7.asp */
TargetPath: string;
/** Saves a shortcut object to disk.
* @see https://www.vbsedit.com/html/a6e33ae0-25ba-4a11-80ee-94764565be54.asp */
Save: () => void;
}
/** Provides access to the native Windows shell.
* @see https://www.vbsedit.com/html/7b956233-c1aa-4b59-b36d-f3e97a9b02f0.asp */
interface WshShell {
/** Returns an environment variable's expanded value.
* @see https://www.vbsedit.com/html/c1c1f29c-2a30-46a1-bae7-c17f8af55a19.asp */
ExpandEnvironmentStrings: (
/** String value indicating the name of the environment variable you want to expand. */
String: string,
) => string;
/** Runs a program in a new process.
* @see https://www.vbsedit.com/html/6f28899c-d653-4555-8a59-49640b0e32ea.asp */
Run: (
/** String value indicating the command line you want to run. You must include any parameters you want to pass to the executable file. */
Command: string,
/** Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.*/
WindowStyle?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10,
/** Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script. If set to `true`, script execution halts until the program finishes, and `Run` returns any error code returned by the program. If set to `false` (the default), the `Run` method returns immediately after starting the program, automatically returning `0` (not to be interpreted as an error code). */
WaitOnReturn?: boolean,
) => number;
/** Creates a new shortcut, or opens an existing shortcut.
* @see https://www.vbsedit.com/html/d91b9d23-a7e5-4ec2-8b55-ef6ffe9c777d.asp */
CreateShortcut: (
/** String value indicating the pathname of the shortcut to create. */
Pathname: string,
) => WshShortcut;
}
/** Provides access to a computer's file system.
* @see https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/filesystemobject-object */
interface FileSystemObject {
/** Returns a string containing the name of the parent folder of the last component in a specified path.
* @see https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/getparentfoldername-method */
GetParentFolderName: (
/** The path specification for the component whose parent folder name is to be returned. */
Path: string,
) => string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment