mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
406 lines
18 KiB
406 lines
18 KiB
//+---------------------------------------------------------------------------
|
|
//
|
|
// Microsoft Windows
|
|
// Copyright (C) Microsoft Corporation, 1992 - 1995
|
|
//
|
|
// File: mtscript.idl
|
|
//
|
|
// Contents: Definition of Script engine interfacets
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#include "dispid.h"
|
|
|
|
#define RC_INVOKED
|
|
|
|
#undef ASSERT
|
|
|
|
#define DEFAULTVALUE_(x) ,defaultvalue(x)
|
|
#ifndef MTSCRIPT_DROP
|
|
#define MTSCRIPT_QFENUMBER 0
|
|
#define MTSCRIPT_BUILDNUMBER 0
|
|
#endif
|
|
|
|
#define VERSIONNUMBER MTSCRIPT_BUILDNUMBER.MTSCRIPT_QFENUMBER
|
|
// ************* Script Engine Interfaces *****************
|
|
|
|
[uuid(854c3169-c854-4a77-b189-606859e4391b), version(1.0)]
|
|
library MTScriptEngine
|
|
{
|
|
importlib("stdole2.tlb");
|
|
const long IConnectedMachine_lVersionMajor = MTSCRIPT_BUILDNUMBER;
|
|
const long IConnectedMachine_lVersionMinor = MTSCRIPT_QFENUMBER;
|
|
|
|
// ****************************************************************
|
|
// DUAL INTERFACES
|
|
// ****************************************************************
|
|
|
|
[uuid(854c3181-c854-4a77-b189-606859e4391b), dual]
|
|
interface IRemoteMTScriptProxy : IDispatch
|
|
{
|
|
HRESULT Connect([in, defaultvalue("")] BSTR bstrMachine);
|
|
HRESULT Disconnect();
|
|
HRESULT DownloadFile([in] BSTR bstrUrl,
|
|
[out, retval] BSTR *bstrFile);
|
|
}
|
|
|
|
[uuid(854c316c-c854-4a77-b189-606859e4391b), dual, version(VERSIONNUMBER)]
|
|
interface IConnectedMachine : IDispatch
|
|
{
|
|
[helpstring("Fires an OnRemoteExec event on the script engine")]
|
|
HRESULT Exec([in] BSTR bstrCmd,
|
|
[in] BSTR bstrParams,
|
|
[out, retval] VARIANT *pvData);
|
|
|
|
[propget,
|
|
helpstring("Returns the data that was published by the script engine")]
|
|
HRESULT PublicData([out, retval] VARIANT *pvData);
|
|
|
|
[propget,
|
|
helpstring("The machine name")]
|
|
HRESULT Name([out, retval] BSTR *name);
|
|
|
|
[propget,
|
|
helpstring("The machine platform (intel, alpha, etc)")]
|
|
HRESULT Platform([out, retval] BSTR *platform);
|
|
|
|
[propget,
|
|
helpstring("The machine operating system (WinNT, Win95, Win98, etc)")]
|
|
HRESULT OS([out, retval] BSTR *os);
|
|
|
|
[propget,
|
|
helpstring("Major OS Version (Raw data from OSVERSIONINFO)")]
|
|
HRESULT MajorVer([out, retval] long *majorver);
|
|
|
|
[propget,
|
|
helpstring("Minor OS Version (Raw data from OSVERSIONINFO)")]
|
|
HRESULT MinorVer([out, retval] long *minorver);
|
|
|
|
[propget,
|
|
helpstring("OS Build number (Raw data from OSVERSIONINFO)")]
|
|
HRESULT BuildNum([out, retval] long *buildnum);
|
|
|
|
[propget,
|
|
helpstring("Returns true if the machine is running NT")]
|
|
HRESULT PlatformIsNT([out, retval] VARIANT_BOOL *pfIsNT);
|
|
|
|
[propget,
|
|
helpstring("Returns any service pack string for OS")]
|
|
HRESULT ServicePack([out, retval] BSTR *servicepack);
|
|
|
|
[propget,
|
|
helpstring("IConnectedMachine Major Version")]
|
|
HRESULT HostMajorVer([out, retval] long *majorver);
|
|
|
|
[propget,
|
|
helpstring("IConnectedMachine Minor Version")]
|
|
HRESULT HostMinorVer([out, retval] long *minorver);
|
|
|
|
[propget,
|
|
helpstring("Get status value by index.")]
|
|
HRESULT StatusValue([in] long nIndex, [out, retval] long *pnStatus);
|
|
}
|
|
|
|
// This interface is not intended to ever be remoted or marshalled
|
|
[uuid(854c316b-c854-4a77-b189-606859e4391b), dual, local]
|
|
interface IGlobalMTScript : IDispatch
|
|
{
|
|
[propget,
|
|
helpstring("MTScript Major Version")]
|
|
HRESULT HostMajorVer([out, retval] long *majorver);
|
|
|
|
[propget,
|
|
helpstring("MTScript Minor Version")]
|
|
HRESULT HostMinorVer([out, retval] long *minorver);
|
|
|
|
[propget,
|
|
helpstring("A place to store global data that is visible to other clients which connect to this machine")]
|
|
HRESULT PublicData([out, retval] VARIANT *pvData);
|
|
|
|
[propput]
|
|
HRESULT PublicData([in] VARIANT vData);
|
|
|
|
[propget,
|
|
helpstring("A place to store global data that should not be made visible to clients which connect")]
|
|
HRESULT PrivateData([out, retval] VARIANT *pvData);
|
|
|
|
[propput]
|
|
HRESULT PrivateData([in] VARIANT vData);
|
|
|
|
[helpstring("Quits the MTScript process")]
|
|
HRESULT ExitProcess();
|
|
|
|
[helpstring("Shuts down all running scripts and restarts")]
|
|
HRESULT Restart();
|
|
|
|
[propget,
|
|
helpstring("Returns the local machine's name")]
|
|
HRESULT LocalMachine([out, retval] BSTR *pbstrName);
|
|
|
|
[helpstring("Behaves similar to the C/C++ #include. Parses in the given script file.")]
|
|
HRESULT Include(BSTR bstrPath);
|
|
|
|
[helpstring("Execute script file in the same thread as the caller. Param is available to script as 'ScriptParam'.")]
|
|
HRESULT CallScript(
|
|
[in] BSTR Path,
|
|
[optional, in] VARIANT *Param);
|
|
|
|
[helpstring("Execute script file in a new thread. Param is available to script as 'ScriptParam'.")]
|
|
HRESULT SpawnScript(
|
|
[in] BSTR Path,
|
|
[optional, in] VARIANT *Param);
|
|
|
|
[propget,
|
|
helpstring("Argument passed to 'CallScript' or 'SpawnScript'")]
|
|
HRESULT ScriptParam(
|
|
[out, retval] VARIANT *Param);
|
|
|
|
[propget,
|
|
helpstring("Returns the path of the scripts used by the script engine")]
|
|
HRESULT ScriptPath([out, retval] BSTR *pbstrPath);
|
|
|
|
[helpstring("Call external function in specified DLL")]
|
|
HRESULT CallExternal([in] BSTR bstrDLLName,
|
|
[in] BSTR bstrFunctionName,
|
|
[in,optional] VARIANT *pParam,
|
|
[out,retval] long *pdwRetVal);
|
|
|
|
[helpstring("Resets multiple ThreadSyncs with the given name to non-signaled. On error, reset no ThreadSyncs.")]
|
|
HRESULT ResetSync([in] const BSTR bstrName);
|
|
|
|
[helpstring("Waits for a ThreadSync with the given name to be signaled")]
|
|
HRESULT WaitForSync([in] BSTR bstrName, // Name of ThreadSync
|
|
[in] long nTimeout, // Timeout in ms
|
|
[out, retval] VARIANT_BOOL *pfSignaled); // TRUE if event was signaled, FALSE on timeout
|
|
|
|
[helpstring("Waits for multiple ThreadSyncs with the given names to be signaled")]
|
|
HRESULT WaitForMultipleSyncs([in] const BSTR bstrNameList, // Comma separated list of ThreadSync names
|
|
[in] VARIANT_BOOL fWaitForAll, // If TRUE, all listed syncs must be signaled
|
|
[in] long nTimeout, // Timeout in millisec
|
|
[out, retval] long *plSignal); // Index of signaled ThreadSync. 0 if timed-out, 1 if fWaitForAll=true
|
|
|
|
[helpstring("Sets the given (1 or more) ThreadSyncs to signaled. They stays signaled until ResetSync is called")]
|
|
HRESULT SignalThreadSync([in] BSTR bstrName);
|
|
|
|
[helpstring("Obtains a thread lock with the given name (a.k.a. critical section")]
|
|
HRESULT TakeThreadLock([in] BSTR bstrName);
|
|
|
|
[helpstring("Obtains a thread lock with the given name (a.k.a. critical section")]
|
|
HRESULT ReleaseThreadLock([in] BSTR bstrName);
|
|
|
|
[helpstring("Gives the script thread a chance to handle cross-thread communication")]
|
|
HRESULT DoEvents();
|
|
|
|
// BUGBUG -- Need to design better feedback/error UI
|
|
|
|
[helpstring("Puts up a messagebox.")]
|
|
HRESULT MessageBoxTimeout([in] BSTR bstrMessage, // Message Text
|
|
[in] long cButtons, // Number of buttons (max 5)
|
|
[in] BSTR bstrButtonText, // Comma separated list of button text. Number must match cButtons
|
|
[in] long lTimeout, // Timeout in minutes. If zero then no timeout.
|
|
[in] long lEventInterval, // Fire a OnMessageBoxInterval event every lEventInterval minutes
|
|
[in] VARIANT_BOOL fCanCancel, // If TRUE then timeout can be canceled.
|
|
[in] VARIANT_BOOL fConfirm, // If TRUE then confirm the button pushed before returning.
|
|
[out, retval] long *plSelected); // Returns button pushed. 0=timeout, 1=Button1, 2=Button2, etc.
|
|
|
|
[helpstring("Runs a command on the local machine")]
|
|
HRESULT RunLocalCommand([in] BSTR bstrCommand, // Command to run (does not wrap it in a shell)
|
|
[in] BSTR bstrDir, // Directory to use as working directory.
|
|
[in, DEFAULTVALUE_("")] BSTR bstrTitle, // The window title to use (if bstrCommand invokes a shell)
|
|
[in, DEFAULTVALUE_(0)] VARIANT_BOOL fMinimize, // If TRUE, the new process is started minimized
|
|
[in, DEFAULTVALUE_(0)] VARIANT_BOOL fGetOutput, // If TRUE, capture STDOUT and STDERR and make available using GetProcessOutput()
|
|
[in, DEFAULTVALUE_(-1)] VARIANT_BOOL fWait, // If TRUE, doesn't return until finished
|
|
[in, DEFAULTVALUE_(-1)] VARIANT_BOOL fNoCrashPopup,// If TRUE, unhandled exceptions in the child process just terminate the process
|
|
[in, DEFAULTVALUE_(0)] VARIANT_BOOL fNoEnviron, // If TRUE, invoke it with an empty environment
|
|
[out, retval] long *plProcessID); // ID of new process, 0 on error.
|
|
|
|
[helpstring("Returns the error code from RunLocalCommand if it failed")]
|
|
HRESULT GetLastRunLocalError([out, retval] long *plErrorCode);
|
|
|
|
[helpstring("Returns the STDOUT & STDERR data for the process up to this point")]
|
|
HRESULT GetProcessOutput([in] long lProcessID,
|
|
[out, retval] BSTR *pbstrData);
|
|
|
|
[helpstring("Returs the exit code for the given process")]
|
|
HRESULT GetProcessExitCode([in] long lProcessID, [out, retval] long *plExitCode);
|
|
|
|
[helpstring("Terminates the given running process")]
|
|
HRESULT TerminateProcess([in] long lProcessID); // Calls IScriptedProcessSink::RequestExit first if the process is connected
|
|
|
|
[helpstring("Sends information to a process connected through IScriptedProcess")]
|
|
HRESULT SendToProcess([in] long lProcessID,
|
|
[in] BSTR bstrType,
|
|
[in] BSTR bstrData,
|
|
[out, retval] long *plReturn);
|
|
|
|
[helpstring("Sends email using MAPI")]
|
|
HRESULT SendMail([in] BSTR bstrTo, // To line, separated by spaces
|
|
[in] BSTR bstrCC, // CC line, separated by spaces
|
|
[in] BSTR bstrBCC, // BCC line, separated by spaces
|
|
[in] BSTR bstrSubject,
|
|
[in] BSTR bstrMessage,
|
|
[in, DEFAULTVALUE_("")] BSTR bstrAttachmentPath,
|
|
[in, DEFAULTVALUE_("")] BSTR bstrUsername, // Login username
|
|
[in, DEFAULTVALUE_("")] BSTR bstrPassword, // Login password
|
|
[out, retval] long *plErrorCode);
|
|
|
|
[helpstring("Sends email using SMTP")]
|
|
HRESULT SendSMTPMail([in] BSTR bstrFrom, // Sender - must be a valid address w/ domain. e.g. "[email protected]"
|
|
[in] BSTR bstrTo, // To line, separated by spaces, must have domain
|
|
[in] BSTR bstrCC, // CC line, separated by spaces, must have domain
|
|
[in] BSTR bstrSubject,
|
|
[in] BSTR bstrMessage,
|
|
[in] BSTR bstrSMTPHost, // Name of SMTP Host to send mail through
|
|
[out, retval] long *plErrorCode);
|
|
|
|
[helpstring("If 'Assertion' = True then Assert with 'Message'.")]
|
|
HRESULT ASSERT(
|
|
[in] VARIANT_BOOL Assertion,
|
|
[in] BSTR Message);
|
|
|
|
[helpstring("Output 'Message' to debug console.")]
|
|
HRESULT OUTPUTDEBUGSTRING(
|
|
[in] BSTR Message);
|
|
|
|
[helpstring("Uneval the string")]
|
|
HRESULT UnevalString([in] BSTR bstrIn,
|
|
[out, retval] BSTR *bstrOut);
|
|
|
|
[helpstring("Copy or append one file to another. Return lastbytecopied+1")]
|
|
HRESULT CopyOrAppendFile(
|
|
[in] BSTR bstrSrc, // File to READ
|
|
[in] BSTR bstrDst, // File to WRITE
|
|
[in] long nSrcOffset, // Offset in READ file to start reading from
|
|
[in] long nSrcLength, // Max # of bytes to READ (pass -1 to read to EOF)
|
|
[in] VARIANT_BOOL fAppend, // If true, append to WRITE file, else always create WRITE file
|
|
[out, retval] long *nSrcFilePosition); // The resultant position in the READ file. Pass this as nSrcOffset on the next call to this function to continue reading.
|
|
|
|
[helpstring("Sleeps n milliseconds")]
|
|
HRESULT Sleep([in] int nTimeout);
|
|
|
|
[helpstring("Reboots the local machine")]
|
|
HRESULT Reboot();
|
|
|
|
[helpstring("Fires the OnScriptNotify event to any clients connected to us through the RemoteMTScript object")]
|
|
HRESULT NotifyScript(BSTR bstrEvent, VARIANT vData);
|
|
|
|
[helpstring("Registers the given object so that events can be hooked up")]
|
|
HRESULT RegisterEventSource([in] IDispatch *pDisp, [in, DEFAULTVALUE_("")] BSTR bstrProgID);
|
|
|
|
[helpstring("Unregisters an object registered with RegisterEventSource")]
|
|
HRESULT UnregisterEventSource([in] IDispatch *pDisp);
|
|
|
|
[propget,
|
|
helpstring("Get status value by index.")]
|
|
HRESULT StatusValue([in] long nIndex, [out, retval] long *pnStatus);
|
|
|
|
[propput,
|
|
helpstring("Get status value by index.")]
|
|
HRESULT StatusValue([in] long nIndex, [in] long nStatus);
|
|
}
|
|
|
|
// ****************************************************************
|
|
// EVENT INTERFACES
|
|
// ****************************************************************
|
|
|
|
|
|
[uuid(854c316a-c854-4a77-b189-606859e4391b)]
|
|
dispinterface DLocalMTScriptEvents
|
|
{
|
|
properties:
|
|
methods: // Events
|
|
//
|
|
//
|
|
[helpstring("Main function called when script is loaded"),
|
|
id(DISPID_MTScript_ScriptMain)] void ScriptMain();
|
|
|
|
[helpstring("Fired when another machine connects to this machine through the RemoteMTScript object with the intent of controlling us"),
|
|
id(DISPID_MTScript_OnMachineConnect)]
|
|
void OnMachineConnect();
|
|
|
|
[helpstring("Fired when a connected machines calls Exec()"),
|
|
id(DISPID_MTScript_OnRemoteExec)]
|
|
void OnRemoteExec([in] BSTR bstrCmd,
|
|
[in] BSTR bstrParams,
|
|
[out, retval] VARIANT *pvDataReturn);
|
|
|
|
// This event is only fired on the thread that received the call to
|
|
// RegisterEventSource for that object.
|
|
[helpstring("Fired when the object fires an event"),
|
|
id(DISPID_MTScript_OnEventSourceEvent)]
|
|
void OnEventSourceEvent([in] IDispatch *pDisp,
|
|
[in] long lDispid);
|
|
|
|
// This event is only fired on the thread that called RunLocalCommand
|
|
// for that process.
|
|
[helpstring("Fired to give info on a process created with RunLocalCommand"),
|
|
id(DISPID_MTScript_OnProcessEvent)]
|
|
void OnProcessEvent([in] long lProcessID, // Process ID
|
|
[in] BSTR bstrEvent, // String giving event name
|
|
[in] VARIANT vData, // Data associated with the event
|
|
[out, retval] long *plReturn); // Return value
|
|
|
|
// This event is only fired on the script thread that made the call
|
|
// to MessageBoxTimeout.
|
|
[helpstring("Fired by MessageBoxTimeout() every specified number of minutes when timing out."),
|
|
id(DISPID_MTScript_OnMessageBoxInterval)]
|
|
void OnMessageBoxInterval();
|
|
|
|
// This event is fired when a script error occurs.
|
|
// A return value is expected.
|
|
// If 0 is returned, mtscript.exe displays a dialog
|
|
// If 1 is returned mtscript invokes the script debugger (if present)
|
|
// else the error is ignored.
|
|
// MTScript.exe always records the error via OUTPUTDEBUGSTRING.
|
|
[helpstring("Invoked on script error"),
|
|
id(DISPID_MTScript_OnScriptError)]
|
|
void OnScriptError([in] BSTR bstrFile,
|
|
[in] long nLine,
|
|
[in] long nChar,
|
|
[in] BSTR bstrText,
|
|
[in] long sCode,
|
|
[in] BSTR bstrSource,
|
|
[in] BSTR bstrDescription,
|
|
[out, retval] VARIANT *pvDataReturn);
|
|
}
|
|
|
|
[uuid(854c3170-c854-4a77-b189-606859e4391b)]
|
|
dispinterface DRemoteMTScriptEvents
|
|
{
|
|
properties:
|
|
methods: // Events
|
|
//
|
|
//
|
|
[helpstring("Fired when a connected machine calls NotifyScript event"),
|
|
id(DISPID_RemoteMTScript_OnScriptNotify)]
|
|
void OnScriptNotify(BSTR bstrIdent, VARIANT vInfo);
|
|
}
|
|
|
|
// ****************************************************************
|
|
// COCLASSES
|
|
// ****************************************************************
|
|
|
|
[uuid(854c316e-c854-4a77-b189-606859e4391b),
|
|
noncreatable]
|
|
coclass LocalMTScript
|
|
{
|
|
[default] interface IGlobalMTScript;
|
|
[default, source] dispinterface DLocalMTScriptEvents;
|
|
}
|
|
|
|
|
|
[uuid(854c316d-c854-4a77-b189-606859e4391b)]
|
|
coclass RemoteMTScript
|
|
{
|
|
[default] interface IConnectedMachine;
|
|
[default, source] dispinterface DRemoteMTScriptEvents;
|
|
}
|
|
|
|
|
|
[uuid(854c3182-c854-4a77-b189-606859e4391b)]
|
|
coclass RemoteMTScriptProxy
|
|
{
|
|
[default] interface IRemoteMTScriptProxy;
|
|
[default, source] dispinterface DRemoteMTScriptEvents;
|
|
}
|
|
}
|