mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Windows Script Host objects
This commit is contained in:
@@ -1,3 +1,49 @@
|
||||
let obj1 = new ActiveXObject('WScript.Network');
|
||||
const wshn = new ActiveXObject('WScript.Network');
|
||||
|
||||
let obj2 = new ActiveXObject('WScript.Shell');
|
||||
// https://msdn.microsoft.com/en-us/library/s6wt333f(v=vs.84).aspx
|
||||
// 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');
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/kxsdca3c(v=vs.84).aspx
|
||||
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:");
|
||||
for (let i = 0; i < drives.length; i += 2) {
|
||||
WScript.Echo(`Drive ${drives.Item(i)} = ${drives.Item(i + 1)}`);
|
||||
}
|
||||
WScript.Echo('');
|
||||
WScript.Echo("Network printer mappings:");
|
||||
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');
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/d16d7wbf(v=vs.84).aspx
|
||||
wshn.RemoveNetworkDrive('E:');
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/tsbh2yy7(v=vs.84).aspx
|
||||
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);
|
||||
})();
|
||||
|
||||
+42
-2
@@ -114,19 +114,59 @@ declare namespace IWshRuntimeLibrary {
|
||||
class WshNetwork {
|
||||
private 'IWshRuntimeLibrary.WshNetwork_typekey': WshNetwork;
|
||||
private constructor();
|
||||
AddPrinterConnection(LocalName: string, RemoteName: string, UpdateProfile?: any, UserName?: any, Password?: any): void;
|
||||
|
||||
/**
|
||||
* Adds a remote MS-DOS-based printer connection to your computer system.
|
||||
* @param LocalName Local name to assign to the connected printer.
|
||||
* @param RemoteName Name of the remote printer.
|
||||
* @param UpdateProfile [false] Whether the printer mapping is stored in the current user's profile.
|
||||
*
|
||||
* If you are mapping a remote printer using the profile of someone other than current user, you can specify _UserName_ and _Password_.
|
||||
*/
|
||||
AddPrinterConnection(LocalName: string, RemoteName: string, UpdateProfile?: boolean, UserName?: string, Password?: string): void;
|
||||
|
||||
/**
|
||||
* @param string Path to printer connection
|
||||
* @param string [DriverName='']
|
||||
* @param string [Port='LPT1']
|
||||
*
|
||||
* Unlike the **AddPrinterConnection** method, this method allows you to create a printer connection without directing it to a specific port, such as LPT1.
|
||||
*/
|
||||
AddWindowsPrinterConnection(PrinterName: string, DriverName?: string, Port?: string): void;
|
||||
readonly ComputerName: string;
|
||||
EnumNetworkDrives(): WshCollection;
|
||||
EnumPrinterConnections(): WshCollection;
|
||||
MapNetworkDrive(LocalName: string, RemoteName: string, UpdateProfile?: any, UserName?: any, Password?: any): void;
|
||||
|
||||
/**
|
||||
* Adds a remote MS-DOS-based printer connection to your computer system.
|
||||
* @param LocalName Name by which the mapped drive will be known locally
|
||||
* @param RemoteName Share's UNC name (\\xxx\yyy)
|
||||
* @param UpdateProfile [false] Whether the printer mapping is stored in the current user's profile.
|
||||
*
|
||||
* If you are mapping a network drive using the profile of someone other than current user, you can specify _UserName_ and _Password_.
|
||||
*/
|
||||
MapNetworkDrive(LocalName: string, RemoteName: string, UpdateProfile?: boolean, UserName?: string, Password?: string): void;
|
||||
readonly Organization: string;
|
||||
|
||||
/**
|
||||
* Removes a shared network drive from your computer system
|
||||
* @param Name Name of the mapped drive you want to remove. This will be the drive letter if the drive has a mapping between a local name (drive letter) and a remote name (UNC name);
|
||||
* it will be the UNC path if there is no such mapping
|
||||
* @param Force [false] Remove the connections even if the resource is in use
|
||||
* @param UpdateProfile [false] Remove the mapping from the user's profile
|
||||
*/
|
||||
RemoveNetworkDrive(Name: string, Force?: any, UpdateProfile?: any): void;
|
||||
|
||||
/**
|
||||
* Removes a shared network printer connection from your computer system
|
||||
* @param Name Name that identifies the printer. Can be a UNC name (in the form `\\xxx\yyy`) or a local name (such as `LPT1`)
|
||||
* @param Force [false] Remove printer connection even if a user is still connected
|
||||
* @param UpdateProfile [false] Remove the printer connection from the user's profile
|
||||
*
|
||||
* The **RemovePrinterConnection** method removes both Windows and MS-DOS based printer connections. If the printer was connected using the method **AddPrinterConnection**,
|
||||
* _Name_ must be the printer's local name. If the printer was connected using the **AddWindowsPrinterConnection** method or was added manually (using the Add Printer wizard),
|
||||
* then _Name_ must be the printer's UNC name.
|
||||
*/
|
||||
RemovePrinterConnection(Name: string, Force?: any, UpdateProfile?: any): void;
|
||||
SetDefaultPrinter(Name: string): void;
|
||||
readonly Site: string;
|
||||
|
||||
Reference in New Issue
Block a user