diff --git a/types/windows-script-host/index.d.ts b/types/windows-script-host/index.d.ts
index b74ba7736c..d348f3d20d 100644
--- a/types/windows-script-host/index.d.ts
+++ b/types/windows-script-host/index.d.ts
@@ -159,6 +159,23 @@ declare namespace IWshRuntimeLibrary {
AtEndOfStream: boolean;
}
+ /** Provides access to the entire collection of command-line parameters, in the order in which they were originally entered. */
+ interface WshArguments {
+ Count(): number;
+ Item(index: number): string;
+ Length: number;
+ Named: WshNamed;
+
+ /**
+ * When you run the **ShowUsage** method, a help screen (referred to as the usage) appears and displays details about the script's command line options.
+ * This information comes from the runtime section of the `*.WSF` file. Everything written between the `` and `` tags is pieced together
+ * to produce what is called a "usage statement." The usage statement tells the user how to use the script.
+ */
+ ShowUsage(): void;
+ Unnamed: WshUnnamed;
+ (index: number): string;
+ }
+
/** Generic Collection Object */
interface WshCollection {
Count(): number;
@@ -171,7 +188,7 @@ declare namespace IWshRuntimeLibrary {
interface WshEnvironment {
Count(): number;
Item(Name: string): string;
- readonly length: number;
+ readonly Length: number;
Remove(Name: string): void;
(Name: string): string;
}
@@ -189,6 +206,19 @@ declare namespace IWshRuntimeLibrary {
Terminate(): void;
}
+ /**
+ * Provides access to the named command-line arguments
+ *
+ * Note that enumerating over this object returns the **names** of the arguments, not the values
+ */
+ interface WshNamed {
+ Count(): number;
+ Exists(Key: string): boolean;
+ Item(name: string): string;
+ Length: number;
+ (name: string): string;
+ }
+
/** Network Object */
class WshNetwork {
private 'IWshRuntimeLibrary.WshNetwork_typekey': WshNetwork;
@@ -388,6 +418,14 @@ declare namespace IWshRuntimeLibrary {
WorkingDirectory: string;
}
+ /** Provides access to the unnamed command-line arguments */
+ interface WshUnnamed {
+ Count(): number;
+ Item(index: number): string;
+ Length: number;
+ (index: number): string;
+ }
+
/** URLShortcut Object */
class WshURLShortcut {
private 'IWshRuntimeLibrary.WshURLShortcut_typekey': WshURLShortcut;
@@ -417,7 +455,7 @@ declare var WScript: {
* Can be accessed only while using CScript.exe.
*/
StdOut: IWshRuntimeLibrary.TextStreamWriter;
- Arguments: { length: number; Item(n: number): string; };
+ Arguments: IWshRuntimeLibrary.WshArguments;
/**
* The full path of the currently running script.
diff --git a/types/windows-script-host/windows-script-host-tests.ts b/types/windows-script-host/windows-script-host-tests.ts
index 7bd4e876b5..d4851f2626 100644
--- a/types/windows-script-host/windows-script-host-tests.ts
+++ b/types/windows-script-host/windows-script-host-tests.ts
@@ -1 +1,30 @@
-WScript.Echo(WScript.Arguments.length);
+const collectionToArray = (col: { Item(key: any): T }): T[] => {
+ const results: T[] = [];
+ const enumerator = new Enumerator(col);
+ enumerator.moveFirst();
+ while (!enumerator.atEnd()) {
+ results.push(enumerator.item());
+ enumerator.moveNext();
+ }
+ return results;
+};
+
+// Show all of the arguments.
+WScript.Echo(`${WScript.Arguments.Length} arguments`);
+
+for (const arg of collectionToArray(WScript.Arguments)) {
+ WScript.Echo(` ${arg}`);
+}
+
+// Show the unnamed arguments.
+WScript.Echo(`${WScript.Arguments.Unnamed.Length} unnamed arguments`);
+
+for (const unnamed of collectionToArray(WScript.Arguments.Unnamed)) {
+ WScript.Echo(` ${unnamed}`);
+}
+
+// Show the named arguments.
+WScript.Echo(`${WScript.Arguments.Named.Length} named arguments`);
+for (const key of collectionToArray(WScript.Arguments.Named)) {
+ WScript.Echo(` ${key}=${WScript.Arguments.Named(key)}`);
+}