PLAM.RU


  • ActiveX
  • WSH
  • WSH
  • JScript VBScript
  • Windows (Windows Explorer)
  • , cscript.exe
  • , wscript.exe
  • WSH5.6
  • WScript
  • Arguments
  • StdErr, StdIn, StdOut
  • CreateObject
  • ConnectObject
  • DisconnectObject
  • Echo
  • Sleep
  • -
  • WshArguments
  • WshNamed
  • WshUnnamed
  • WshEnvironment
  • WshSpecialFolders
  • Windows
  • WshNetwork
  • AddPrinterConnection
  • AddWindowsPrinterConnection
  • EnumNetworkDrives
  • EnumPrinterConnections
  • MapNetworkDrive
  • RemoveNetworkDrive
  • RemovePrinterConnection
  • SetDefaultPrinter
  • WshShell
  • Activate
  • CreateShortcut
  • Environment
  • ExpandEnvironmentString
  • LogEvent
  • Popup
  • RegDelete
  • RegRead
  • RegWrite
  • Run
  • SendKeys
  • WshShortcut
  • Arguments
  • HotKey
  • IconLocation
  • WindowStyle
  • WorkingDirectory
  • WshUrlShortcut
  • WshScriptExec
  • ProcessID
  • Status
  • StdOut, StdIn StdErr
  • WshController
  • WshRemote
  • WshRemoteError
  • 1

    Windows Script Host

    Windows () Resource Kit . Windows NT/2000/XP cmd.exe - - (script): , Windows ..

    Microsoft WSH Windows Script Host, , , , ( , (scripting engine), ActiveX Scripting). Visual Basic Script Edition (VBScript) JScript.

    , , WSH, ActiveX, ActiveX Microsoft.

    ActiveX

    , Windows (OLE, Object Linking and Embedding). OLE , () . , ( ), ( ), OLE Automation. OLE OLE Automation Microsoft "" COM (Component Object Model).

    , , , , . , . , . , - , (), , , .

    , Microsoft, OLE . Microsoft 1996 ActiveX, WWW (World Wide Web) (), .

    ActiveX Microsoft. Microsoft Office, Internet Explorer, IIS (Internet Information Service). : VBScript ( Microsoft Office, Internet Explorer, IIS) JScript ( Internet Explorer, IIS). , , , VBScript JScript, .

    WSH , ( ) (VBScript, JScript, PerlScript, REXX, TCL, Python ..), , , ActiveX. WSH Windows, HTML-.

    WSH

    WSH. WSH, Windows 98, 1.0. , JScript VBScript 5.0, Internet Explorer 5.0, WSH WSH 5.0. WSH, Windows 2000, 2.0; JScript VBScript 5.1. , WSH, Windows , Microsoft JScript VBScript WSH 5.6.

    , "WSH" Microsoft "Windows Scripting Host", "Windows Script Host".

    , WSH 5.6 Windows , 32- Windows 95/98/ME/NT/2000. WSH 5.6 Microsoft (http://msdn.microsoft.com/scripting); WSH 5.6.

    WSH

    WSH Windows. WSH, , ( ). , .

    , WSH.

    ? , - .

    ? Windows , .

    ? Microsoft Office, , .

    ? , , .

    ? ( ).

    ? .

    ? (, ).

    JScript VBScript

    WSH-, JScript VBScript, js vbs , , " ".

    , , 3.

    , .

    JScript-, "!" (. 1.1).

    . 1.1.


    , , Windows (notepad.exe) First.js, :

    WScript.Echo("!");

    VBScript, , :

    WScript.Echo "!"

    , , : , , . JScript , , :

    /*******************************************************************/

    /* : First.js */

    /* : JScript*/

    /* : */

    /*******************************************************************/

    . 1.2. First.js


    VBScript :

    '*******************************************************************

    ': First.vbs

    ': VBScript

    ' :

    '*******************************************************************

    WSH .

    WSH cscript.exe. , , C:\Script\First.js,

    cscript :\Script\First.js

    "!" (. 1.3).

    . 1.3. First.js (cscript.exe)

    () WSH wscript.exe.

    wscript C:\Script\First.js

    (. 1.4).

    , , ( ), .

    . 1.4. First.js (wscript.exe)

    (Run) (Start), (Open) (. 1.5).

    . 1.5. Windows


    wscript.exe, .. .

    Windows (Windows Explorer)

    Windows (. 1.6).

    . 1.6. Windows


    , (Start), wscript.exe.

    , . (cscript.exe) (wscript.exe) -.

    , cscript.exe

    cscript.exe (. 1.1), WSH ( //).


    1.1. cscript.exe

    //I
    ( ).
    //B
    .
    //:nn
    - , .. nn , .
    //Logo
    ( ) WSH
    //Nologo
    WSH
    //H:CScript
    //H:Wscript
    cscript. wscript.exe . , wscript.exe
    //S
    //?
    //E:engine
    , engine
    //D
    //X
    //Job:<JobID>
    JobID
    WS- ( WS- 3)
    //U
    / Unicode

    ,

    cscript //Nologo C:\Script\First.js

    First.js WSH (. 1.7).

    , ( ,

    WshArguments
    ,
    WshNamed
    WshUnnamed
    ). ,

    cscript // C:\Script\First.js / /b

    First.js ,

    /
    /b
    ,
    //B
    cscript.exe.

    . 1.7. First.js WSH


    , wscript.exe

    wscript.exe (Script) , Windows (. 1.8).

    wsh, ini-, :

    [ScriptFile]

    Path=C:\Script\First.js

    [Options]

    Timeout=0

    DisplayLogo=1

    Windows wsh- , (wscript.exe cscript.exe) , wsh- , Options .

    wsh-a , , ScriptFile.

    . 1.8. First.js


    wscript.exe drag-and-drop Windows , , .

    WSH5.6

    WSH 5.6. WSH :

    ? ( ) Windows;

    ? (. . ) , ;

    ? , , ;

    ? ;

    ? ;

    ? : , ;

    ? ;

    ? Windows;

    ? Windows;

    ? .

    WSH 5.6 :

    ?

    WScript
    . WSH, , , Windows.

    ?

    WshArguments
    . Windows.

    ?

    WshNamed
    . .

    ?

    WshUnnamed
    . .

    ?

    WshShell
    . , , , Windows.

    ?

    WshSpecialFolders
    . Windows.

    ?

    WshShortcut
    . Windows.

    ?

    WshUrlShortcut
    . .

    ?

    WshEnvironment
    . , .

    ?

    WshNetwork
    . : , .

    ?

    WshScriptExec
    . , .

    ?

    WshController
    . .

    ?

    WshRemote
    . , .

    ?

    WshRemoteError
    . , , .

    , FileSystemObject, ( 5).

    WSH.

    , , JScript. WSH , JScript, VBScript .

    WScript

    WScript
    (wscript.exe cscript.exe), , , ( ). ,
    WScript
    .
    WScript
    ( ) Windows.

    , WSH

    WScript
    , - , . . .
    CreateObject
    , .

    WScript
    . 1.2.


    1.2.

    WScript

    Application
    IDispatch
    WScript
    Arguments
    WshArguments
    ,
    FullName
    ( Windows C:\WINDOWS\SYSTEM32\CSCRIPT.EXE C:\WINDOWS\SYSTEM32\WSCRIPT.EXE)
    Name
    Wscript
    (Windows Script Host)
    Path
    , cscript.exe wscript.exe ( Windows C:\WINDOWS\SYSTEM32)
    ScriptFullName
    ScriptName
    StdErr
    StdIn
    StdOut
    Version
    WSH

    WScript, .

    Arguments

    ( 1.1) for , .

    1.1.

    /*******************************************************************/

    /* : ShowArgs.js */

    /* : JScript */

    /* : */

    /*******************************************************************/

    var i, objArgs;

    objArgs = WScript.Arguments; // WshArguments

    for (i=0; i<=objArgs.Count()-1; i++)

    WScript.Echo(objArgs(i)); // i-

    /************* *********************************************/

    1.4, 1.5, 2.22 2.23.

    StdErr, StdIn, StdOut

    StdIn
    ,
    StdOut
    StdErr
    , cscript.exe. wscript.exe, "
    Invalid Handle
    " (. 1.9).

    . 1.9.

    StdIn


    StdOut
    StdErr
    Write
    ,
    WriteLine
    ,
    WriteBlankLines
    ,
    StdIn
    Read
    ,
    ReadLine
    ,
    ReadAll
    ,
    Skip
    ,
    SkipLine
    . . 1.3.


    1.3.

    Read(n)
    StdIn
    n
    ReadAll()
    StdIn
    , ASCII 26 (<Ctrl>+<Z>),
    ReadLine()
    ,
    StdIn
    Skip(n)
    StdIn
    n
    SkipLine()
    StdIn
    Write(string)
    StdOut
    StdErr
    string
    ( )
    WriteBlankLines(n)
    StdOut
    StdErr
    n
    WriteLine(string)
    StdOut
    StdErr
    string
    ( )

    , Windows ( "|" ). . , , - (

    FIND
    SORT
    ). , example.js sort.txt:

    cscript //Nologo example.js | sort > sort.txt

    //Nologo , sort.txt WSH.

    , , StdIn, , . . . 1.2.

    1.2.

    /*******************************************************************/

    /* : Interact.js */

    /* : JScript */

    /* : / 堠 */

    /*******************************************************************/

    var s;

    //

    WScript.StdOut.Write(" : ");

    //

    s = WScript.StdIn.ReadLine();

    //

    WScript.StdOut.WriteLine(" " + s);

    /************* *********************************************/

    WScript
    , . 1.4.


    1.4.

    WScript

    CreateObject(strProgID [, strPrefix])
    ,
    strProgID
    ConnectObject(strObject, strPrefix)
    strObject
    , - (
    strPrefix
    )
    DisconnectObject(obj)
    obj
    ,
    Echo([Arg1] [, Arg2] [,])
    GetObject(strPathname [, strProgID], [strPrefix])
    , (
    strPathName
    ), ,
    strProgID
    Quit([intErrorCode])
    intErrorCode
    .
    intErrorCode
    ,
    WScript
    Sleep(intTime)
    ( )
    intTime

    , . 1.4.

    CreateObject

    strProgID
    ,
    CreateObject
    , (Programmic Identifier, ProgID).

    strPrefix
    , , (, ). , ,
    strPrefix
    . ,
    strPrefix
    "
    MYOBJ_
    ", "
    OnBegin
    ", "
    MYOBJ_OnBegin
    ", .

    CreateObject
    WshNetwork
    :

    var WshNetwork = WScript.Createobject("WScript.Network");

    , WSH. JScript

    ActiveXObject
    , :

    var WshNetwork = new ActiveXObject("WScript.Network");

    VBscript

    CreateObject
    , :

    Set WshNetwork = CreateObject("WScript.Network")

    WScript.CreateObject
    .

    ConnectObject

    ,

    ConnectObject
    , .

    MyObject
    "
    SomeObject
    ",
    SomeMetod
    .
    MyObject
    "
    MyEvent
    " . "
    Event
    ",
    MyEvent_Event
    .
    DisconnectObject
    WScript
    MyObject
    .

    var MyObject = WScript.CreateObject("SomeObject");

    MyObject.SomeMethod();

    WScript.ConnectObject(MyObject, "MyEvent");


    function MyEvent_Event(strName) {

    WScript.Echo(strName);

    }

    WScript.DisconnectObject(MyObject);

    DisconnectObject

    obj
    ,
    DisconnectObject(obj)
    .
    DisconnectObject
    .

    Echo

    Arg1
    ,
    Arg2
    . wscript.exe,
    Echo
    , cscript.exe, (). . cscript.exe . Echo , .

    , EchoExample.js ( 1.3) cscript.exe , (. 1.10).

    1.3. EchoExample.js

    /*******************************************************************/

    /* : EchoExample.js */

    /* : JScript */

    /* : WScript.Echo */

    /*******************************************************************/

    WScript.Echo(); //

    WScript.Echo(1,2,3); //

    WScript.Echo("!"); //

    /************* *********************************************/

    . 1.10. Echo


    Echo
    2 (. 2.1, 2.2, 2.4 2.5).

    Sleep

    5 :

    WScript.Echo(" , ...");

    WScript.Sleep(5000);

    WScript.Echo(" ");

    Sleep
    - , ,
    WshShell.SendKeys
    (. 1.13, 2.31, 2.32).

    -

    WSH , , :

    ? Windows (

    WshArguments
    ,
    WshNamed
    WshUnnamed
    );

    ? (

    WshEnvironment
    );

    ? Windows (

    WshSpecialFolders
    ).

    WshArguments

    WshArguments
    Windows.
    Arguments
    WScript
    WshShortcut
    .

    ,

    WshArguments
    JScript
    Enumerator
    moveNext
    ,
    item
    atEnd
    . , , , ( 1.4).

    1.4. ( JScript)

    /********************************************************************/

    /* : EnumArgs.js */

    /* : JScript */

    /* : */

    /********************************************************************/

    var objArgs, e, x;

    objArgs = WScript.Arguments; // WshArguments

    // Enumerator objArgs

    e = new Enumerator(objArgs);

    for (;!e.atEnd();e.moveNext()) {

    x = e.item(); //

    WScript.Echo(x); //

    }

    /************* *********************************************/

    Count
    Item
    WshArguments
    (
    Item
    WSH).
    Count
    , . . ,
    Item(n)
    n- ( ). ,
    WshArguments
    , .

    Length
    WshArguments
    .

    , ( 1.5).

    1.5. ( WSH)

    /*******************************************************************/

    /* : ShowArgs.js */

    /* : JScript */

    /* : */

    /*******************************************************************/

    var i, objArgs;

    objArgs = WScript.Arguments; // WshArguments

    for (i=0; i<=objArgs.Count()-1; i++)

    WScript.Echo(objArgs(i)); // i-

    /************* *********************************************/

    WshArguments
    , (,
    /Name:Andrey
    ) . , , . . , .

    WshArguments
    :
    Named
    Unnamed
    .

    Named
    WshNamed
    ,
    Unnamed
    WshUnnamed
    .

    , :

    ? ( , )

    WshArguments
    ;

    ? , ( )

    WshNamed
    ;

    ? , ( )

    WshUnnamed
    .

    WshArguments
    ShowUsage
    . ( , ..). , WSH- XML;
    ShowUsage
    3
    <runtime>
    ,
    <description>
    ,
    <example>
    ,
    <named>
    <unnamed>
    .

    WshNamed

    WshNamed
    , ( ). WSH 5.6 "/", , ":" , :

    /Name:Andrey

    , . , , . :

    /Name:"Andrey Popov"

    WshNamed

    Named
    WshArguments
    . , .

    Length
    WshNamed
    ;
    Count
    .

    , MyScript.js :

    MyScript.js /User:Andrey /Computer:Server1

    Name Computer :

    var objNamedArgs;

    objNamedArgs=WScript.Arguments.Named;

    WScript.Echo(" : "+objNamedArgs.Item("User"));

    WScript.Echo(" : "+objNamedArgs.Item ("Computer"));

    var objNamedArgs;

    objNamedArgs=WScript.Arguments.Named;

    WScript.Echo(" : "+objNamedArgs("User"));

    WScript.Echo(" : "+objNamedArgs("Computer"));

    , , , , , :

    MyScript.js /User:"Andrey Popov" /Computer:Server1

    MyScript.js :

    WScript.Echo(" : "+ WScript.Arguments.Named("User"));

    : Andrey Popov

    , ,

    Exists
    WshNamed
    . ,

    if (WScript.Arguments.Named.Exists("User"))

    WScript.Echo(" : "+ WScript.Arguments.Named("User"));

    , WshNamed, 2 (. 2.22 2.23).

    WshUnnamed

    WshUnnamed
    , ( ).
    Unnamed
    WshArguments
    . , ( ).

    Length
    WshUnnamed
    ;
    Count
    .

    , MyScript.js :

    MyScript.js "Andrey Popov" Server1

    MyScript.js :

    var objUnnamedArgs;

    obUnnamedArgs=WScript.Arguments.Unnamed;

    WScript.Echo(" : "+objUnnamedArgs.Item(0));

    WScript.Echo(" : "+objUnnamedArgs.Item(1));

    var objUnnamedArgs;

    obUnnamedArgs=WScript.Arguments.Unnamed;

    WScript.Echo(" : "+objUnnamedArgs(0));

    WScript.Echo(" : "+objUnnamedArgs(1));

    :

    : Andrey Popov

    : Server1

    ,

    WshUnnamed
    , 2 (. 2.22 2.23).

    WshEnvironment

    WshEnvironment
    , ( , ).
    Environment
    WshShell
    :

    var WshShell=WScript.Createobject("WScript.Shell"),

    WshSysEnv=WshShell.Environment,

    WshUserEnv=WshShell.Environment("User");

    WshEnvironment
    Length
    , ( ),
    Count
    Item
    . ,
    Item
    .
    PATH
    :

    var WshShell=WScript.CreateObject("WScript.Shell"), WshSysEnv=WshShell.Environment;

    WScript.Echo(" :", WshSysEnv.Item("PATH"));

    :

    WScript.Echo(" :",WshSysEnv("PATH");

    , WshEnvironment Remove(strName), . , 1.6 , (

    EXAMPLE_1
    EXAMPLE_2
    ) .

    EXAMPLE_1
    EXAMPLE_2
    ,
    Remove
    .

    1.6.

    /*******************************************************************/

    /* : RemEnv.js */

    /* : JScript */

    /* : */

    /*******************************************************************/

    // WshShell

    var WshShell = WScript.CreateObject("WScript.Shell");

    // WshEnvironment

    var WshUsrEnv = WshShell.Environment("User");

    //

    WshUsrEnv.Remove("EXAMPLE_1");

    WshUsrEnv.Remove("EXAMPLE_2");

    /************* *********************************************/

    WshSpecialFolders

    WshSpecialFolders
    , Windows (, (Start)); , , .

    Windows 9 :

    ? Desktop;

    ? Favorites;

    ? Fonts;

    ? MyDocuments;

    ? NetHood;

    ? PrintHood;

    ? Programs;

    ? Recent;

    ? SendTo;

    ? StartMenu;

    ? Startup;

    ? Templates.

    Windows NT/2000/XP , :

    ? AllUsersDesktop;

    ? AllUsersStartMenu;

    ? AllUsersPrograms;

    ? AllUsersStartup.

    WshSpecialFolders
    c
    SpecialFolders
    WshShell
    :

    var WshShell=WScript.CreateObject("WScript.Shell"),

    WshSpecFold=WshShell.SpecialFolders;

    WSH,

    WshSpecialFolders
    Length
    Count
    Item
    . , ( 1.7).

    1.7.
    WshSpecialFolders

    /*******************************************************************/

    /* : ShowSpecFold.js */

    /* : JScript */

    /* : Windows */

    /* ( WshSpecialFolders) */

    /*******************************************************************/

    var WshShell, WshFldrs, i;

    // WshShell

    WshShell = WScript.CreateObject("Wscript.Shell");

    // WshSpecialFolders

    WshFldrs = WshShell.SpecialFolders;

    WScript.Echo(" ...");

    // Desktop

    WScript.Echo("Desktop="+ WshFldrs.item("Desktop"));

    // Favorities

    WScript.Echo("Favorites="+ WshFldrs("Favorites"));

    // Programs

    WScript.Echo("Programs="+ WshFldrs("Programs"));

    WScript.Echo("");

    WScript.Echo(" ...");

    for (i=0;i<= WshFldrs.Count()-1;i++){

    // i- WshFldrs

    WScript.Echo(WshFldrs(i));

    }

    /************* *********************************************/

    Windows 2 (. 2.392.42).

    Windows

    Windows ( , , )

    WshNetwork
    WshShell
    .

    WshNetwork

    WshNetwork
    ; .

    WshNetwork
    :

    var objNet=WScript.CreateObject("WScript.Network");

    . 1.5.


    1.5.

    WshNetwork

    ComputerName
    ,
    UserDomain
    ,
    UserName

    1.8.
    WshNetwork

    /*******************************************************************/

    /* : ShowNetwork.js */

    /* : JScript */

    /* : 蠠 */

    /* */

    /*******************************************************************/

    var objNet;

    // WshNetwork

    objNet = WScript.CreateObject("WScript.Network");

    // ComputerName UserName

    WScript.Echo(" :",objNet.ComputerName);

    WScript.Echo(" :",objNet.UserName);

    /************* *********************************************/


    WshNetwork
    . 1.6.


    1.6.

    WshNetwork

    AddPrinterConnection(strLocalName, strRemoteName [ ,bUpdateProfile] [,strUser] [,strPassword])
    Windows NT/2000/XP:
    AddWindowsPrinterConnection(strPrnPath)
    Windows 9x:
    AddWindowsPrinterConnection(strPrnPath, strDriverName[, strPort])
    Windows .
    AddPrinterConnection
    ,
    EnumNetworkDrives()
    ,
    EnumPrinterConnections()
    ,
    MapNetworkDrive(strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword])
    strRemoteName
    strLocalName
    RemoveNetworkDrive(strName, [bForce], [bUpdateProfile])
    RemovePrinterConnection(strName, [bForce], [bUpdateProfile])
    SetDefaultPrinter(strPrinterName)

    . 1.6 .

    AddPrinterConnection

    bUpdateProfile
    True
    , .

    strUser
    ( )
    strPassword
    () , , , .

    AddPrinterConnection
    \\Server1\Epson
    LPT1
    :

    var WshNetwork = CreateObject("WScript.Network");

    WshNetwork.AddPrinterConnection("LPT1", "\\Server1\Epson");

    AddWindowsPrinterConnection

    strDriverName
    , . Windows 9, , . Windows NT/2000/XP
    strDriverName
    .

    strPort
    , (
    LPT1
    ). Windows NT/2000/XP
    strPort
    .

    AddWindowsPrinterConnection
    LPT1
    ( ):

    varWshNetwork=CreateObject("WScript.Network");

    PrinterPath="\\printserv\DefaultPrinter";

    PrinterDriver="Lexmark Optra S 1650";

    WshNetwork.AddwindowsPrinterConnection(PrinterPath, PrinterDriver);

    EnumNetworkDrives

    , , . , ; .

    , , ( 1.9).

    1.9.
    EnumNetworkDrives

    /*******************************************************************/

    /* : ShowNetDrives.js */

    /* : JScript */

    /* : */

    /* ⠠ */

    /*******************************************************************/

    var WshNetwork,oDrives,i;

    // WshNetwork

    WshNetwork = WScript.CreateObject("WScript.Network");

    //

    oDrives = WshNetwork.EnumNetworkDrives();

    for (i=0; i<=oDrives.Count()-1; i++)

    WScript.Echo(oDrives.Item(i)); // i-

    /************* *********************************************/

    EnumPrinterConnections

    , . , ,

    EnumNetworkDrives
    .

    , ( 1.10).

    1.10.
    EnumPrinterConnections

    /*******************************************************************/

    /* : ShowNetPrn.js */

    /* : JScript */

    /* : */

    /* ⠠ */

    /*******************************************************************/

    // WshNetwork

    var WshNetwork = WScript.CreateObject("WScript.Network");

    //

    var oPrinters = WshNetwork.EnumPrinterConnections();

    for (i=0; i<=oPrinters.Count()-1; i++)

    WScript.Echo(oPrinters.Item(i)); // i-

    /************* *********************************************/

    MapNetworkDrive

    bUpdateProfile
    True
    , .

    strUser
    ( )
    strPassword
    () , , , .

    "

    z
    " \\Server1\Programs:

    var WshNetwork = WScript.CreateObject("WScript.Network");

    WshNetwork.MapNetworkDrive("Z:","\\Server1\Programs");

    RemoveNetworkDrive

    strName
    ( ), ( ); , . ,
    strName
    . ,
    strName
    .

    bForce
    True
    , , .

    bUpdateProfile
    True
    , .

    "z" , ( 1.11).

    1.11.

    /*******************************************************************/

    /* : MapDrive.js */

    /* : JScript */

    /* : / ࠠ */

    /*******************************************************************/

    // WshNetwork

    var WshNetwork = WScript.CreateObject("WScript.Network");

    // Z:\ \\Server1\Programs

    WshNetwork.MapNetworkDrive("Z:","\\Server1\Programs");

    // Z:\

    WshNetwork.RemoveNetworkDrive("Z:");

    /************* *********************************************/

    RemovePrinterConnection

    strName
    ( ), ( ); , . (, LPT1),
    strName
    . ,
    strName
    .

    bForce
    bUpdateProfile
    ,
    RemoveNetworkDrive
    .

    ,

    LPT1
    :

    var WshNetwork = WScript.CreateObject("WScript.Network");

    WshNetwork.RemovePrinterConnection("LPT1:");

    SetDefaultPrinter

    strName
    , .

    AddPrinterConnection
    LPT1: \\Server1\Epson, ( 1.12).

    1.12.
    SetDefaultPrinter

    /*******************************************************************/

    /* : DefPrn.js */

    /* : JScript */

    /* : */

    /*******************************************************************/

    // WshNetwork

    var WshNetwork = WScript.CreateObject("WScript.Network");

    // LPT1 \\Server1\Epson

    WshNetwork.AddPrinterConnection("LPT1:","\\Server1\Epson");

    //

    WshNetwork.SetDefaultPrinter("\\Server1\Epson");

    /************* *********************************************/

    ,

    WshNetwork
    , 2 (. 2.472.52).

    WshShell

    WshShell
    , , , Windows. :

    var WshShell=WScript.CreateObject("WScript.Shell");

    WshShell
    , . 1.7.


    1.7.

    WshShell

    CurrentDirectory
    ( , )
    Environment
    WshEnvironment
    , Windows NT/2000/XP Windows 9
    SpecialFolders
    WshSpecialFolders
    Windows ( , (Start) ..)

    ,

    WshShell
    (. 1.8).


    1.8.

    WshShell

    AppActivate(title)
    title
    .
    title
    (, "calc" "notepad") (ProcessID, PID)
    CreateShortcut(strPathname)
    WshShortcut
    Windows ( lnk)
    WshUrlShortcut
    ( url).
    strPathname
    Environment(strType)
    WshEnvironment
    ,
    Exec(strCommand)
    , ,
    strCommand
    .
    WshScriptExec
    ,
    StdIn
    ,
    StdOut
    StdErr
    ExpandEnvironmentStrings(strString)
    ,
    strString
    ( "%")
    LogEvent(intType, strMessage [ ,strTarget])
    Windows NT/2000/XP WSH.log.
    int
    ,
    strMessage
    .
    strTarget
    Windows NT/2000/XP, , ( ).
    LogEvent
    true
    ,
    false
    Popup(strt, [nSecToWait] , [strTitle], [nType])
    ,
    strText
    .
    nSecToWait
    , ,
    strTitle
    ,
    nType
    RegDelete(strName)
    RegRead(strName)
    RegWrite(strName, anyValue [,strType])
    Run(strCommand, [intWindowStyle], [bWaitOnReturn])
    , ,
    strCommand
    SendKeys(string)
    ( , )
    SpecialFolders(strSpecFolder)
    , Windows,
    strSpecFolder

    , . 1.8, .

    Activate

    AppActivate
    ( ), . ,
    Run
    WshShell
    . , ,
    title
    . , ,
    title
    . , , . , ( ).

    AppActivate
    1.13 RunCalc.js, Windows (
    SendKeys
    ).

    1.13. RunCalc.js

    /*****************************************************************/

    /* : RunCalc.js */

    /* : JScript */

    /* : ࠠ */

    /*****************************************************************/

    // WshShell

    var WshShell = WScript.CreateObject("WScript.Shell");

    //

    WshShell.Run("calc");

    // 0,1

    WScript.Sleep(100);

    //

    WshShell.AppActivate("Calculator");

    // 0,1

    WScript.Sleep(100);

    //

    WshShell.SendKeys("1{+}");

    WScript.Sleep(500);

    WshShell.SendKeys("2");

    WScript.Sleep(500);

    WshShell.SendKeys("~");

    WScript.Sleep(2500);

    /************* *********************************************/

    2

    AppActivate
    (. 2.31 2.32).

    CreateShortcut

    .

    1.14 , (

    oShellLink
    (
    oUrlLink
    ).

    1.14.
    CreateShortcut

    /*****************************************************************/

    /* : MakeShortcuts.js */

    /* : JScript */

    /* : */

    /*****************************************************************/

    var WshShell,oShellLink,oUrlLink;

    // WshShell

    WshShell=WScript.CreateObject("WScript.Shell");

    //

    oShellLink=WshShell.CreateShortcut("Current Script.lnk");

    //

    oShellLink.TargetPath=WScript.ScriptFullName;

    //

    oShellLink.Save();

    //

    oUrlLink = WshShell.CreateShortcut("Microsoft Web Site.URL");

    // URL

    oUrlLink.TargetPath = "http://www.microsoft.com";

    //

    oUrlLink.Save();

    /************* *********************************************/

    1.191.24, 2.43 2.44.

    Environment

    strType
    ,
    WshEnvironment
    ; "System" ( ), "User" ( ), "Volatile" ( ) "Process" ( ).

    Windows 9

    strType
    "Process".

    , Windows NT/2000/XP (

    NUMBER_OF_PROCESSORS
    ), Windows ( 1.15).

    1.15. (
    WshShell.Environment
    )

    /*****************************************************************/

    /* : ShowEnvir.js */

    /* : JScript */

    /* : */

    /*****************************************************************/

    var WshShell,WshSysEnv;

    // WshShell

    WshShell = WScript.CreateObject("WScript.Shell");

    // WshEnvironment

    WshSysEnv = WshShell.Environment("SYSTEM");

    WScript.Echo(WshSysEnv("NUMBER_OF_PROCESSORS"));

    WScript.Echo(WshShell.Environment.Item("WINDIR"));

    /************* *********************************************/

    ExpandEnvironmentString

    Windows ( 1.16).

    1.16. (
    ExpandEnvironmertStrings
    )

    /*****************************************************************/

    /* : ExpEnvStr.js */

    /* : JScript */

    /* : Windows */

    /* : */

    /* ExpandEnvironmentString */

    /*****************************************************************/

    var WS = WScript.CreateObject("WScript.Shell");

    WScript.Echo(" Windows:"+WS.ExpandEnvironmentStrings("%WinDir%"));

    /************* *********************************************/

    LogEvent

    Windows NT/2000/XP , Windows 9 WSH.log, Windows. WSH.log , . . 1.9.


    1.9. (

    intType
    )

    0
    SUCCESS
    4
    INFORMATION
    1
    ERROR
    8
    AUDIT_SUCCESS
    2
    WARNING
    16
    AUDIT_FAILURE

    ( , ,

    RunLoginScript
    true,
    false
    ):

    var WshShell = WScript.CreateObject("WScript.Shell");

    rc = RunLoginScript();

    if (rc) WshShell.LogEvent(0,"Logon Script Completed Successfully");

    else WshShell.LogEvent(1,"Logon Script failed");

    Popup

    strTitle
    , "Windows Script Host."

    nType
    ,
    MessageBox
    Microsoft Win32 API. . 1.10 nType ( MessageBox Windows API).


    1.10.

    Popup

    nType
    Visual Basic
    0
    vbOkOnly
    OK
    1
    vbOkCancel
    OK
    (Cancel)
    2
    vbAbortRetryIgnore
    (Abort), (Retry) (Ignore)
    3
    vbYesNoCancel
    (Yes), (No) (Cancel)
    4
    vbYesNo
    (Yes) (No)
    5
    vbRetryCancel
    (Retry) (Cancel)
    16
    vbCritical
    Stop Mark
    32
    vbQuestion
    Question Mark
    48
    vbExclamation
    Exclamation Mark
    64
    vbInformation
    Information Mark

    , VBScript,

    vbOkCancel
    . JScript-, (,
    var vbOkCancel=1;
    ). , .

    Popup
    , . 1.10. , :

    var WshShell = WScript.CreateObject("WScript.Shell");

    WshShell.Popup(" ", 5, "",65);

    , . 1.11, 5 .

    . 1.11. ,

    Popup


    Popup , , (. 1.11).


    1.11.

    Popup

    Visual Basic
    -1 ,
    nSecToWait
    1
    vbOk
    OK
    2
    vbCancel
    (Cancel)
    3
    vbAbort
    (Abort)
    4
    vbRetry
    (Retry)
    5
    vbIgnore
    (Ignore)
    6
    vbYes
    (Yes)
    7
    vbNo
    (No)

    Popup
    2 (. 2.13 2.14).

    RegDelete

    strName
    \\
    , ( ), .
    strName
    (. 1.12).


    1.12.

    HCKU
    HKEY_CURRENT_USER
    HKLM
    HKEY_LOCAL_MACHINE
    HKCR
    HKEY_CLASSES_ROOT
    HKEY_USERS
    HKEY_CURRENT_CONFIG

    ,

    RegDelete
    , 2 (. 2.45 2.46).

    RegRead

    :

    REG_SZ
    ,
    REG_EXPAND_SZ
    ,
    REG_DWORD
    ,
    REG_BINARY
    REG_MULTI_SZ
    . ,
    RegRead
    DISP_E_TYPEMISMATCH
    .

    strName
    \\
    , ( ), .

    RegRead
    ( 1.17).

    1.17.

    /********************************************************************/

    /* : RegRead.js */

    /* : JScript */

    /* : */

    /********************************************************************/

    var WS,s;

    // WshShell

    WS = WScript.CreateObject("WScript.Shell");

    s=" \n";

    s+="HKCU\\Control Panel\\Keyboard\\KeyboardSpeed = ";

    //

    s+=WS.RegRead("HKCU\\Control Panel\\Keyboard\\KeyboardSpeed")+"\n\n";

    s+=" \n";

    s+="HKCU\\Control Panel\\Keyboard\\ = ";

    //

    s+=WS.RegRead("HKCU\\Control Panel\\Keyboard\\");

    //

    WScript.Echo(s);

    /************* ***********************************************/

    RegWrite

    strName
    \\
    , ; , .
    strName
    \\
    , ; , .

    anyValue
    ,
    strName
    .
    strType
    .
    strType
    "
    REG_SZ
    ", "
    REG_EXPAND_SZ
    ", "
    REG_DWORD
    " "
    REG_BINARY
    ".
    strType
    ,
    RegWrite
    E_INVALIDARG
    .

    ,

    strType
    "
    REG_SZ
    " "
    REG_EXPAND_SZ
    ",
    RegWrite
    anyValue
    .
    strType
    "
    REG_DWORD
    ",
    anyValue
    . strType "
    REG_BINARY
    ",
    anyValue
    .

    , RegWrite, 2 (. 2.45 2.46).

    Run

    intWindowStyle
    (. 1.13).


    1.13. (

    intWindowStyle
    )

    Visual Basic
    0
    vbHide
    ( )
    1
    vbNormalFocus
    . , .
    2
    vbMinimizedFocus
    ()
    3
    vbMaximizedFocus
    ()
    4
    vbNormalNoFocus
    , .
    5
    6 vbMinimizedNoFocus ( Z-)
    7 .
    8 .
    9 . , . , (
    Run
    )
    10 , ,

    , VBScript,

    vbHide
    . JScript-, (,
    var vbHide=0;
    ). , .

    bWaitOnReturn
    , .
    false
    , ( ).
    bWaitOnReturn
    true
    , .

    bWaitOnReturn
    true
    ,
    Run
    .
    bWaitOnReturn
    false
    ,
    Run
    .

    (notepad.exe) :

    var WshShell = WScript.CreateObject("WScript.Shell");

    WshShell.Run("%windir%\\notepad" + WScript.ScriptFullName);

    ( 1.18).

    1.18.

    /********************************************************************/

    /* : RetCode.js */

    /* : JScript */

    /* : */

    /********************************************************************/

    // WshShell

    var WshShell = WScript.CreateObject("WScript.Shell");

    //

    Return = WshShell.Run("notepad " + WScript.ScriptFullName, 1, true);

    //

    WScript.Echo(" :", Return);

    /************* ***********************************************/

    Run 2 (. 2.31 2.32).

    SendKeys

    . , , ,

    SendKeys
    "
    ":
    string="AB"
    .

    SendKeys :

    +
    ,
    ^
    ,
    %
    ,
    ~
    ,
    (
    ,
    )
    . ,
    {}
    . ,
    {+}
    .
    []
    SendKeys , . , :
    {{}
    ( )
    {}}
    ( ).

    , <Enter> <Tab> ,

    SendKeys
    , . 1.14.


    1.14.

    SendKeys

    <Backspace>
    {BACKSPACE}
    ,
    {BS}
    {BKSP}
    <>>
    {RIGHT}
    <Break>
    {BREAK}
    <F1>
    {F1}
    <Caps Lock>
    {CAPSLOCK}
    <F2>
    {F2}
    <Del> <Delete>
    {DELETE}
    {DEL}
    <F3>
    {F3}
    <End>
    {END}
    <F4>
    {F4}
    <Enter>
    {ENTER}
    ~
    <F5>
    {F5}
    <Esc>
    {ESC}
    <F6>
    {F6}
    <Home>
    {HELP}
    <F7>
    {F7}
    <Ins> <Insert>
    {INSERT}
    {INS}
    <F8>
    {F8}
    <Num Lock>
    {NUMLOCK}
    <F9>
    {F9}
    <Page Down>
    {PGDN}
    <F10>
    {F10}
    <Page Up>
    {PGUP}
    <F11>
    {F11}
    <Print Screen>
    {PRTSC}
    <F12>
    {F12}
    <Scroll Lock>
    {SCROLLLOCK}
    <F13>
    {F13}
    <Tab>
    {TAB}
    <F14>
    {F14}
    <^>
    {UP}
    <F15>
    {F15}
    <<>
    {LEFT}
    <F16>
    {F16}
    <v> {DOWN}

    <Shift>, <Ctrl> <Alt>, . 1.15.


    1.15. <Shift>, <Ctrl> <Alt>

    <Shift>
    +
    <Ctrl>
    ^
    <Alt>
    %

    , , <Shift>, <trl> <Alt>, . , <G> <S> <Shift>, "

    +(GS)
    ". , <Shift>+<G>, <S> ( <Shift>), "
    +GS
    ".

    SendKeys . , . ,

    {LEFT 42}
    <<> 42 ;
    {h 10}
    <h> 10 .

    SendKeys
    , Microsoft Windows (, MS-DOS).

    ,

    SendKeys
    , 1.13, 2.31, 2.32.

    Windows WSH:

    WshShortcut
    WshUrlShortcut
    .

    WshShortcut

    WshShortcut
    Windows .
    CreateShortcut
    WshShell
    . 1.19 , ( ).

    1.19.

    /*****************************************************************/

    /* : MakeShortcut1.js */

    /* : JScript */

    /* : 頠 */

    /*****************************************************************/

    var WshShell,oShellLink;

    // WshShell

    WshShell = WScript.CreateObject("WScript.Shell");

    //

    oShellLink = WshShell.CreateShortcut("Current Script.lnk");

    //

    oShellLink.TargetPath = WScript.ScriptFullName;

    //

    oShellLink.Save();

    /************* *********************************************/

    WshShortcut
    . 1.16.


    1.16.

    WshShortcut

    Arguments
    ,
    Description
    FullName
    HotKey
    "" , .. , ,
    IconLocation
    TargetPath
    ,
    WindowStyle
    ,
    WorkingDirectory
    ,

    WshShortcut
    .

    Arguments

    1.20 , .

    1.20.

    /*****************************************************************/

    /* : MakeShortcut2.js */

    /* : JScript */

    /* : 񠠠 */

    /* 蠠 */

    /*****************************************************************/

    var WshShell,oShellLink;

    // WshShell

    WshShell = WScript.CreateObject("WScript.Shell");

    //

    oShellLink = WshShell.CreateShortcut("Current Script.lnk");

    //

    oShellLink.TargetPath = WScript.ScriptFullName;

    //

    oShellLink.Arguments = "-a abc.txt";

    //

    oShellLink.Save();

    /************* *********************************************/

    HotKey

    "" ,

    HotKey
    , , "
    +
    ".

    "" , Windows (Start). "" , , .

    ( 1.21) , "" <Ctrl>+ +<Alt>+<D>.

    1.21. ""

    /*****************************************************************/

    /* : MakeShortcut3.js */

    /* : JScript */

    /* : */

    /* */

    /*****************************************************************/

    var WshShell,strDesktop,oMyShortcut;

    // WshShell

    WshShell = WScript.CreateObject("WScript.Shell");

    //

    strDesktop = WshShell.SpecialFolders("Desktop");

    //

    oMyShortcut = WshShell.CreateShortcut(strDesktop+"\\a_key.lnk");

    //

    oMyShortcut.TargetPath =

    WshShell.ExpandEnvironmentStrings("%windir%\\notepad.exe");

    //

    oMyShortcut.Hotkey = "CTRL+ALT+D";

    //

    oMyShortcut.Save();

    WScript.Echo(" : "+oMyShortcut.Hotkey);

    /************* *********************************************/

    IconLocation

    ,

    IconLocation
    : ", ". , , ( ).

    ( 1.22) ( 0) notepad.exe.

    1.22. notepad.exe

    /*****************************************************************/

    /* : MakeShortcut4.js */

    /* : JScript */

    /* : 頠 */

    /* notepad.exe */

    /*****************************************************************/

    var WshShell,oShellLink;

    // WshShell

    WshShell = WScript.CreateObject("WScript.Shell");

    //

    oShellLink = WshShell.CreateShortcut("Current Script.lnk");

    //

    oShellLink.TargetPath = WScript.ScriptFullName;

    // notepad.exe

    oShellLink.IconLocation = "notepad.exe, 0";

    //

    oShellLink.Save();

    /************* *********************************************/

    WindowStyle

    WindowStyle
    intWindowStyle
    , , . 1.17.


    1.17.

    intWindowStyle

    IntWindowStyle
    1 . ,
    3 ()
    7 ()

    WorkingDirectory

    ( 1.23) , :.

    1.23.

    /*****************************************************************/

    /* : MakeShortcut5.js */

    /* : JScript */

    /* :  */

    /* ࠠ */

    /*****************************************************************/

    var WshShell,oShellLink;

    // WshShell

    WshShell = WScript.CreateObject("WScript.Shell");

    //

    oShellLink = WshShell.CreateShortcut("Notepad.lnk");

    //

    oShellLink.TargetPath = "notepad.exe";

    //

    oShellLink.WorkingDirectory = "c:\\";

    //

    oShellLink.Save();

    /************* *********************************************/

    WshShortcut
    Save
    , ,
    FullName
    .

    WshUrlShortcut

    WshUrlShortcut
    . ,
    WshShortcut
    ,
    CreateShortcut
    WshShell
    .

    ( 1.24) www.microsoft.com.

    1.24.

    /*****************************************************************/

    /* : MakeShortcut6.js */

    /* : JScript */

    /* : www.microsoft.com */

    /*****************************************************************/

    var WshShell,oUrlLink;

    // WshShell

    WshShell = WScript.CreateObject("WScript.Shell");

    //

    oUrlLink = WshShell.CreateShortcut("Microsoft Web Site.URL");

    //

    oUrlLink.TargetPath = "http://www.microsoft.com";

    //

    oUrlLink.Save();

    /************* *********************************************/

    WshUrlShortcut
    :
    FullName
    TargetPath
    ,
    WshShortcut
    .

    WshUrlShortcut
    Save
    , ,
    FullName
    .

    WshShortcut
    2 (. 2.43 2.44).

    WSH 5.6 , / .

    WshScriptExec
    .

    , , , . , ,

    WshController
    ,
    WshRemote
    WshRemoteError
    .

    WshScriptExec

    WSH 5.6

    WshShell.Exec
    , .. , -.
    WshShell.Exec
    , ,
    WScriptExec
    , / ( , , , ).

    ,

    WshShell.Exec
    Windows-.
    WshScriptExec
    , (Process ID, PID),
    WshShell.AppActivate
    .

    WScriptExec
    Terminate
    , .

    :

    var WshShell=WScript.CreateObject("WScript.Shell");

    var ChildJob = WshShell.Exec("cscript ChildScript.js");

    ChildJob.Terminate();

    Terminate
    ,
    WM_CLOSE
    . , .
    Terminate
    , .. , , . , , , .

    WshScriptExec
    . 1.18.


    1.18.

    WshScriptExec

    ExitCode
    ,
    ProcessID
    (ProcessID, PID),
    WshScriptExec
    Status
    StdOut
    -
    StdIn
    -
    StdErr
    -

    ProcessID

    ( MakeCalc.js)

    ProcessID
    Windows. ,
    WshShell.AppActivate
    "Calculator".

    1.25. PID

    /*****************************************************************/

    /* : MakeCalc.js */

    /* : JScript */

    /* : PID */

    /*****************************************************************/

    var WshShell, theCalculator;

    // WshShell

    WshShell = WScript.CreateObject("WScript.Shell");

    //

    theCalculator = WshShell.Exec("calc");

    // ,

    //

    WScript.Sleep(500);

    //

    WshShell.AppActivate(theCalculator.ProcessID);

    //

    WshShell.SendKeys("1{+}");

    WScript.Sleep(500);

    WshShell.SendKeys("2");

    WScript.Sleep(500);

    WshShell.SendKeys("~");

    /************* *********************************************/

    Status

    - , , , .

    Status
    :
    Status
    0, , ,
    Status
    1, . , 1.26 ChildStatus.js " " (. 1.12).

    1.26.

    /*****************************************************************/

    /* : ChildStatus.js */

    /* : JScript */

    /* : ࠠ */

    /*****************************************************************/

    var WshShell,theJob;

    // WshShell

    WshShell=WScript.CreateObject("WScript.Shell");

    //

    theJob = WshShell.Exec("xcopy /?");

    for (;;) {

    if (theJob.status==1) //

    break; //

    else WScript.Echo(" ");

    }

    WScript.Echo(" ");

    /************* *********************************************/

    . 1.12. ChildStatus.js

    StdOut, StdIn StdErr

    c

    StdOut
    ,
    StdIn
    StdErr
    WshScriptExec
    ,
    WScript
    (. . 1.3). , 1.27 ConToWin.js wscript.exe, cscript.exe (. 1.13).

    . 1.13. ConToWin.js


    , cscript.exe DOS-, Windows-. DosToWin, : Windows-, :

    function DosToWin(s) {

    var i,ss; //

    //, RusDict

    if (typeof(RusDict)=="undefined")

    // RusDict ,

    MakeRusDict();

    ss="";

    for (i=0;i<s.length;i++) { //

    if (RusDict.Exists(s.charAt(i))) //

    // i- Windows-

    ss+=RusDict.Item(s.charAt(i));

    else ss+=s.charAt(i);

    }

    return ss;

    }

    DosToWin
    Dictionary
    RusDict
    .
    MakeRusDict
    """aee" , DOS-, , Windows-.

    // Dictionary "-",

    //""- DOS-, ""- ,

    // Windows-

    function MakeRusDict() {

    // Dictionary

    RusDict = WScript.CreateObject("Scripting.Dictionary");

    // "" ( DOS-)- "" (

    //Window-)

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    }

    1.27. StdOut

    /*****************************************************************/

    /* : ConToWin.js */

    /* : JScript */

    /* : DOS */

    /* : StdOut ࠠ */

    /*****************************************************************/

    var WshShell,theJob,s,IsBreak,RusDict; //

    // Dictionary "-",

    //""- DOS-, ""- ,

    // Windows-

    function MakeRusDict() {

    // Dictionary

    RusDict = WScript.CreateObject("Scripting.Dictionary");

    // "" ( DOS-)- "" (

    //Window-)

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    RusDict.add("", ""); RusDict.add("", ""); RusDict.add("", "");

    }

    // DOS- Windows-

    function DosToWin(s) {

    var i,ss; //

    //, RusDict

    if (typeof(RusDict)=="undefined")

    // RusDict ,

    MakeRusDict();

    ss="";

    for (i=0;i<s.length;i++) { //

    if (RusDict.Exists(s.charAt(i))) //

    // i- Windows-

    ss+=RusDict.Item(s.charAt(i));

    else ss+=s.charAt(i);

    }

    return ss;

    }

    /************* *********************************************/

    // WshShell

    WshShell=WScript.CreateObject("WScript.Shell");

    //

    theJob = WshShell.Exec("cscript");

    IsBreak=false;

    for (;;) {

    if (!theJob.StdOut.AtEndOfStream)

    // , StdOut

    //

    s+=theJob.StdOut.ReadAll();

    if (IsBreak) break;

    if (theJob.status==1) //,

    IsBreak=true;

    else WScript.Sleep(100);

    }

    // Windows-

    //

    WScript.Echo(DosToWin(s));

    /************* *********************************************/

    , Exec , StdIn StdOut ( 2.37 2.38).

    WshController

    WshController
    CreateScript
    - .

    , Windows NT/2000/XP; , . , WSH ; , , 2.

    WshController :

    var WshController=WScript.CreateObject("WshController");

    ,

    WshController
    (ProgID) "
    WshController
    ", "
    WScript.WshController
    ", - WSH 5.6.

    CreateScript
    WshRemote
    , . WSH :

    ? ;

    ? DCOM

    WshRemote
    ;

    ?

    Execute
    WshRemote
    .

    CreateScript
    :

    CreateScript(CommandLine, [MachineName])

    CommandLine
    , . , , . , , , - ( , , ).

    MachineName
    , . , .

    WshRemote

    WshRemote
    , . , ,
    WshRemote
    , , .
    WshRemote
    CreateScript
    WshController
    :

    var Controller,RemoteScript;

    Controller=WScript.CreateObject("WshController");

    RemoteScript=Controller.CreateScript("d: WscriptsWMyScript.js", "Server1");

    WshRemote
    :
    Error
    Status
    .

    Error
    WshRemoteError
    , , .

    Status
    , .
    Status
    . 1.19.


    1.19.

    Status

    NoTask
    0
    WshRemote
    , , ,
    Running
    1
    Finished
    2

    WshRemote
    (
    Execute
    ) (
    Terminate
    ); .
    Terminate
    ,
    WshScriptExec
    , ,
    WM_CLOSE
    ( , ).

    , WshRemote , . 1.20.


    1.20.

    WshRemote

    Start
    Execute
    Error
    ,
    End
    ( )

    , . 1.20, WshRemote ConnectObject WScript ( 1.28).

    1.28. WshRemote (JScript)

    /**********************************************************************/

    /* : RemoteEvents.js */

    /* : JScript */

    /* : , */

    /* */

    /**********************************************************************/

    Var Controller,RemScript,IsQuit; //

    // WshController

    Controller = WScript.CreateObject("WshController");

    // ( WshRemote)

    RemScript = Controller.CreateScript("D:\RemoteScript.js ", "stand");

    // WshRemote

    WScript.ConnectObject(RemScript, "RemoteScript_");

    RemScript.Execute(); //

    IsQuit = False;

    while (!IsQuit) WScript.Sleep(100); // 0,1

    WScript.Quit(); //

    /*************** - ***********************/

    function RemoteScript_End { // End

    WScript.Echo(" ");

    IsQuit = True;

    }

    function RemoteScript_Error { // Error

    //

    WScript.Echo(" : " +

    RemScript.Error.Description);

    IsQuit = True;

    }

    function RemoteScript_Start { // Start

    WScript.Echo(" ");

    }

    /************* *********************************************/

    WshRemoteError

    WshRemoteError
    .
    WshRemoteError
    Error
    WshRemote
    .

    WshRemoteError
    . 1.21 ( ).


    1.21.

    WshRemoteError

    Description
    , . - ,
    Description
    Line
    , . , ,
    Line
    0
    Character
    , . , ,
    Character
    0
    Number
    SourceText
    , . , ,
    SourceText
    Source
    -,

    Error
    WshRemote
    ; 1.28, 2.56 2.57.









    | | | |

    .