From a02c0315c7f438f1ebebf4435f59c198b5ff02c4 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Thu, 15 Feb 2018 17:31:10 +0200 Subject: [PATCH] Default properties --- .../activex-iwshruntimelibrary-tests.ts | 12 ++++++------ types/activex-iwshruntimelibrary/index.d.ts | 15 ++++----------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/types/activex-iwshruntimelibrary/activex-iwshruntimelibrary-tests.ts b/types/activex-iwshruntimelibrary/activex-iwshruntimelibrary-tests.ts index f39627cc1a..14a90f9a8a 100644 --- a/types/activex-iwshruntimelibrary/activex-iwshruntimelibrary-tests.ts +++ b/types/activex-iwshruntimelibrary/activex-iwshruntimelibrary-tests.ts @@ -4,11 +4,11 @@ const wshn = new ActiveXObject('WScript.Network'); // https://msdn.microsoft.com/en-us/library/wck0hkd7(v=vs.84).aspx // https://msdn.microsoft.com/en-us/library/tte130y1(v=vs.84).aspx // https://msdn.microsoft.com/en-us/library/3fxhka75(v=vs.84).aspx -(() => { +{ WScript.Echo('Domain = ' + wshn.UserDomain); WScript.Echo('Computer Name = ' + wshn.ComputerName); WScript.Echo('User Name = ' + wshn.UserName); -})(); +} // https://msdn.microsoft.com/en-us/library/zsdh7hkb(v=vs.84).aspx wshn.AddWindowsPrinterConnection('\\\\printserv\\DefaultPrinter'); @@ -18,7 +18,7 @@ wshn.AddPrinterConnection("LPT1", "\\\\Server\\Print1"); // https://msdn.microsoft.com/en-us/library/t9zt39at(v=vs.84).aspx // https://msdn.microsoft.com/en-us/library/zhds6k80(v=vs.84).aspx -(() => { +{ const drives = wshn.EnumNetworkDrives(); const printers = wshn.EnumPrinterConnections(); WScript.Echo("Network drive mappings:"); @@ -30,7 +30,7 @@ wshn.AddPrinterConnection("LPT1", "\\\\Server\\Print1"); for (let i = 0; i < printers.length; i += 2) { WScript.Echo(`Port ${printers.Item(i)} = ${printers.Item(i + 1)}`); } -})(); +} // https://msdn.microsoft.com/en-us/library/8kst88h6(v=vs.84).aspx wshn.MapNetworkDrive('E:', '\\\\Server\\Public'); @@ -42,8 +42,8 @@ wshn.RemoveNetworkDrive('E:'); wshn.RemovePrinterConnection('\\\\PRN-CORP1\\B41-4523-A', true, true); // https://msdn.microsoft.com/en-us/library/2ccwwdct(v=vs.84).aspx -(() => { +{ const printerPath = "\\\\research\\library1"; wshn.AddWindowsPrinterConnection(printerPath); wshn.SetDefaultPrinter(printerPath); -})(); +} diff --git a/types/activex-iwshruntimelibrary/index.d.ts b/types/activex-iwshruntimelibrary/index.d.ts index 904f25f102..d5b052eaae 100644 --- a/types/activex-iwshruntimelibrary/index.d.ts +++ b/types/activex-iwshruntimelibrary/index.d.ts @@ -98,22 +98,20 @@ declare namespace IWshRuntimeLibrary { } /** Generic Collection Object */ - class WshCollection { - private 'IWshRuntimeLibrary.WshCollection_typekey': WshCollection; - private constructor(); + interface WshCollection { Count(): number; Item(Index: any): any; readonly length: number; + (Index: any): any; } /** Environment Variables Collection Object */ - class WshEnvironment { - private 'IWshRuntimeLibrary.WshEnvironment_typekey': WshEnvironment; - private constructor(); + interface WshEnvironment { Count(): number; Item(Name: string): string; readonly length: number; Remove(Name: string): void; + (Name: string): string; } /** WSHExec object */ @@ -348,8 +346,3 @@ interface ActiveXObjectNameMap { 'WScript.Network': IWshRuntimeLibrary.WshNetwork; 'WScript.Shell': IWshRuntimeLibrary.WshShell; } - -interface EnumeratorConstructor { - new(col: IWshRuntimeLibrary.WshCollection): Enumerator; - new(col: IWshRuntimeLibrary.WshEnvironment): Enumerator; -}