1 | /*! *****************************************************************************
|
---|
2 | Copyright (c) Microsoft Corporation. All rights reserved.
|
---|
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
---|
4 | this file except in compliance with the License. You may obtain a copy of the
|
---|
5 | License at http://www.apache.org/licenses/LICENSE-2.0
|
---|
6 |
|
---|
7 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
---|
8 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
---|
9 | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
---|
10 | MERCHANTABLITY OR NON-INFRINGEMENT.
|
---|
11 |
|
---|
12 | See the Apache Version 2.0 License for specific language governing permissions
|
---|
13 | and limitations under the License.
|
---|
14 | ***************************************************************************** */
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 | /// <reference no-default-lib="true"/>
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 |
|
---|
23 | /////////////////////////////
|
---|
24 | /// Windows Script Host APIS
|
---|
25 | /////////////////////////////
|
---|
26 |
|
---|
27 |
|
---|
28 | interface ActiveXObject {
|
---|
29 | new (s: string): any;
|
---|
30 | }
|
---|
31 | declare var ActiveXObject: ActiveXObject;
|
---|
32 |
|
---|
33 | interface ITextWriter {
|
---|
34 | Write(s: string): void;
|
---|
35 | WriteLine(s: string): void;
|
---|
36 | Close(): void;
|
---|
37 | }
|
---|
38 |
|
---|
39 | interface TextStreamBase {
|
---|
40 | /**
|
---|
41 | * The column number of the current character position in an input stream.
|
---|
42 | */
|
---|
43 | Column: number;
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * The current line number in an input stream.
|
---|
47 | */
|
---|
48 | Line: number;
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Closes a text stream.
|
---|
52 | * It is not necessary to close standard streams; they close automatically when the process ends. If
|
---|
53 | * you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
---|
54 | */
|
---|
55 | Close(): void;
|
---|
56 | }
|
---|
57 |
|
---|
58 | interface TextStreamWriter extends TextStreamBase {
|
---|
59 | /**
|
---|
60 | * Sends a string to an output stream.
|
---|
61 | */
|
---|
62 | Write(s: string): void;
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Sends a specified number of blank lines (newline characters) to an output stream.
|
---|
66 | */
|
---|
67 | WriteBlankLines(intLines: number): void;
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Sends a string followed by a newline character to an output stream.
|
---|
71 | */
|
---|
72 | WriteLine(s: string): void;
|
---|
73 | }
|
---|
74 |
|
---|
75 | interface TextStreamReader extends TextStreamBase {
|
---|
76 | /**
|
---|
77 | * Returns a specified number of characters from an input stream, starting at the current pointer position.
|
---|
78 | * Does not return until the ENTER key is pressed.
|
---|
79 | * Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
---|
80 | */
|
---|
81 | Read(characters: number): string;
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Returns all characters from an input stream.
|
---|
85 | * Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
---|
86 | */
|
---|
87 | ReadAll(): string;
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Returns an entire line from an input stream.
|
---|
91 | * Although this method extracts the newline character, it does not add it to the returned string.
|
---|
92 | * Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
---|
93 | */
|
---|
94 | ReadLine(): string;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Skips a specified number of characters when reading from an input text stream.
|
---|
98 | * Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
---|
99 | * @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
---|
100 | */
|
---|
101 | Skip(characters: number): void;
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * Skips the next line when reading from an input text stream.
|
---|
105 | * Can only be used on a stream in reading mode, not writing or appending mode.
|
---|
106 | */
|
---|
107 | SkipLine(): void;
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * Indicates whether the stream pointer position is at the end of a line.
|
---|
111 | */
|
---|
112 | AtEndOfLine: boolean;
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * Indicates whether the stream pointer position is at the end of a stream.
|
---|
116 | */
|
---|
117 | AtEndOfStream: boolean;
|
---|
118 | }
|
---|
119 |
|
---|
120 | declare var WScript: {
|
---|
121 | /**
|
---|
122 | * Outputs text to either a message box (under WScript.exe) or the command console window followed by
|
---|
123 | * a newline (under CScript.exe).
|
---|
124 | */
|
---|
125 | Echo(s: any): void;
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Exposes the write-only error output stream for the current script.
|
---|
129 | * Can be accessed only while using CScript.exe.
|
---|
130 | */
|
---|
131 | StdErr: TextStreamWriter;
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * Exposes the write-only output stream for the current script.
|
---|
135 | * Can be accessed only while using CScript.exe.
|
---|
136 | */
|
---|
137 | StdOut: TextStreamWriter;
|
---|
138 | Arguments: { length: number; Item(n: number): string; };
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * The full path of the currently running script.
|
---|
142 | */
|
---|
143 | ScriptFullName: string;
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Forces the script to stop immediately, with an optional exit code.
|
---|
147 | */
|
---|
148 | Quit(exitCode?: number): number;
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * The Windows Script Host build version number.
|
---|
152 | */
|
---|
153 | BuildVersion: number;
|
---|
154 |
|
---|
155 | /**
|
---|
156 | * Fully qualified path of the host executable.
|
---|
157 | */
|
---|
158 | FullName: string;
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * Gets/sets the script mode - interactive(true) or batch(false).
|
---|
162 | */
|
---|
163 | Interactive: boolean;
|
---|
164 |
|
---|
165 | /**
|
---|
166 | * The name of the host executable (WScript.exe or CScript.exe).
|
---|
167 | */
|
---|
168 | Name: string;
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * Path of the directory containing the host executable.
|
---|
172 | */
|
---|
173 | Path: string;
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * The filename of the currently running script.
|
---|
177 | */
|
---|
178 | ScriptName: string;
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * Exposes the read-only input stream for the current script.
|
---|
182 | * Can be accessed only while using CScript.exe.
|
---|
183 | */
|
---|
184 | StdIn: TextStreamReader;
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Windows Script Host version
|
---|
188 | */
|
---|
189 | Version: string;
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
|
---|
193 | */
|
---|
194 | ConnectObject(objEventSource: any, strPrefix: string): void;
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Creates a COM object.
|
---|
198 | * @param strProgiID
|
---|
199 | * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
---|
200 | */
|
---|
201 | CreateObject(strProgID: string, strPrefix?: string): any;
|
---|
202 |
|
---|
203 | /**
|
---|
204 | * Disconnects a COM object from its event sources.
|
---|
205 | */
|
---|
206 | DisconnectObject(obj: any): void;
|
---|
207 |
|
---|
208 | /**
|
---|
209 | * Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
|
---|
210 | * @param strPathname Fully qualified path to the file containing the object persisted to disk.
|
---|
211 | * For objects in memory, pass a zero-length string.
|
---|
212 | * @param strProgID
|
---|
213 | * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
---|
214 | */
|
---|
215 | GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * Suspends script execution for a specified length of time, then continues execution.
|
---|
219 | * @param intTime Interval (in milliseconds) to suspend script execution.
|
---|
220 | */
|
---|
221 | Sleep(intTime: number): void;
|
---|
222 | };
|
---|
223 |
|
---|
224 | /**
|
---|
225 | * WSH is an alias for WScript under Windows Script Host
|
---|
226 | */
|
---|
227 | declare var WSH: typeof WScript;
|
---|
228 |
|
---|
229 | /**
|
---|
230 | * Represents an Automation SAFEARRAY
|
---|
231 | */
|
---|
232 | declare class SafeArray<T = any> {
|
---|
233 | private constructor();
|
---|
234 | private SafeArray_typekey: SafeArray<T>;
|
---|
235 | }
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * Allows enumerating over a COM collection, which may not have indexed item access.
|
---|
239 | */
|
---|
240 | interface Enumerator<T = any> {
|
---|
241 | /**
|
---|
242 | * Returns true if the current item is the last one in the collection, or the collection is empty,
|
---|
243 | * or the current item is undefined.
|
---|
244 | */
|
---|
245 | atEnd(): boolean;
|
---|
246 |
|
---|
247 | /**
|
---|
248 | * Returns the current item in the collection
|
---|
249 | */
|
---|
250 | item(): T;
|
---|
251 |
|
---|
252 | /**
|
---|
253 | * Resets the current item in the collection to the first item. If there are no items in the collection,
|
---|
254 | * the current item is set to undefined.
|
---|
255 | */
|
---|
256 | moveFirst(): void;
|
---|
257 |
|
---|
258 | /**
|
---|
259 | * Moves the current item to the next item in the collection. If the enumerator is at the end of
|
---|
260 | * the collection or the collection is empty, the current item is set to undefined.
|
---|
261 | */
|
---|
262 | moveNext(): void;
|
---|
263 | }
|
---|
264 |
|
---|
265 | interface EnumeratorConstructor {
|
---|
266 | new <T = any>(safearray: SafeArray<T>): Enumerator<T>;
|
---|
267 | new <T = any>(collection: { Item(index: any): T }): Enumerator<T>;
|
---|
268 | new <T = any>(collection: any): Enumerator<T>;
|
---|
269 | }
|
---|
270 |
|
---|
271 | declare var Enumerator: EnumeratorConstructor;
|
---|
272 |
|
---|
273 | /**
|
---|
274 | * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
|
---|
275 | */
|
---|
276 | interface VBArray<T = any> {
|
---|
277 | /**
|
---|
278 | * Returns the number of dimensions (1-based).
|
---|
279 | */
|
---|
280 | dimensions(): number;
|
---|
281 |
|
---|
282 | /**
|
---|
283 | * Takes an index for each dimension in the array, and returns the item at the corresponding location.
|
---|
284 | */
|
---|
285 | getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T;
|
---|
286 |
|
---|
287 | /**
|
---|
288 | * Returns the smallest available index for a given dimension.
|
---|
289 | * @param dimension 1-based dimension (defaults to 1)
|
---|
290 | */
|
---|
291 | lbound(dimension?: number): number;
|
---|
292 |
|
---|
293 | /**
|
---|
294 | * Returns the largest available index for a given dimension.
|
---|
295 | * @param dimension 1-based dimension (defaults to 1)
|
---|
296 | */
|
---|
297 | ubound(dimension?: number): number;
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions,
|
---|
301 | * each successive dimension is appended to the end of the array.
|
---|
302 | * Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6]
|
---|
303 | */
|
---|
304 | toArray(): T[];
|
---|
305 | }
|
---|
306 |
|
---|
307 | interface VBArrayConstructor {
|
---|
308 | new <T = any>(safeArray: SafeArray<T>): VBArray<T>;
|
---|
309 | }
|
---|
310 |
|
---|
311 | declare var VBArray: VBArrayConstructor;
|
---|
312 |
|
---|
313 | /**
|
---|
314 | * Automation date (VT_DATE)
|
---|
315 | */
|
---|
316 | declare class VarDate {
|
---|
317 | private constructor();
|
---|
318 | private VarDate_typekey: VarDate;
|
---|
319 | }
|
---|
320 |
|
---|
321 | interface DateConstructor {
|
---|
322 | new (vd: VarDate): Date;
|
---|
323 | }
|
---|
324 |
|
---|
325 | interface Date {
|
---|
326 | getVarDate: () => VarDate;
|
---|
327 | }
|
---|