Source code of Windows XP (NT5)
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

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: mtscript.idl
  7. //
  8. // Contents: Definition of Script engine interfacets
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "dispid.h"
  12. #define RC_INVOKED
  13. #undef ASSERT
  14. #define DEFAULTVALUE_(x) ,defaultvalue(x)
  15. #ifndef MTSCRIPT_DROP
  16. #define MTSCRIPT_QFENUMBER 0
  17. #define MTSCRIPT_BUILDNUMBER 0
  18. #endif
  19. #define VERSIONNUMBER MTSCRIPT_BUILDNUMBER.MTSCRIPT_QFENUMBER
  20. // ************* Script Engine Interfaces *****************
  21. [uuid(854c3169-c854-4a77-b189-606859e4391b), version(1.0)]
  22. library MTScriptEngine
  23. {
  24. importlib("stdole2.tlb");
  25. const long IConnectedMachine_lVersionMajor = MTSCRIPT_BUILDNUMBER;
  26. const long IConnectedMachine_lVersionMinor = MTSCRIPT_QFENUMBER;
  27. // ****************************************************************
  28. // DUAL INTERFACES
  29. // ****************************************************************
  30. [uuid(854c3181-c854-4a77-b189-606859e4391b), dual]
  31. interface IRemoteMTScriptProxy : IDispatch
  32. {
  33. HRESULT Connect([in, defaultvalue("")] BSTR bstrMachine);
  34. HRESULT Disconnect();
  35. HRESULT DownloadFile([in] BSTR bstrUrl,
  36. [out, retval] BSTR *bstrFile);
  37. }
  38. [uuid(854c316c-c854-4a77-b189-606859e4391b), dual, version(VERSIONNUMBER)]
  39. interface IConnectedMachine : IDispatch
  40. {
  41. [helpstring("Fires an OnRemoteExec event on the script engine")]
  42. HRESULT Exec([in] BSTR bstrCmd,
  43. [in] BSTR bstrParams,
  44. [out, retval] VARIANT *pvData);
  45. [propget,
  46. helpstring("Returns the data that was published by the script engine")]
  47. HRESULT PublicData([out, retval] VARIANT *pvData);
  48. [propget,
  49. helpstring("The machine name")]
  50. HRESULT Name([out, retval] BSTR *name);
  51. [propget,
  52. helpstring("The machine platform (intel, alpha, etc)")]
  53. HRESULT Platform([out, retval] BSTR *platform);
  54. [propget,
  55. helpstring("The machine operating system (WinNT, Win95, Win98, etc)")]
  56. HRESULT OS([out, retval] BSTR *os);
  57. [propget,
  58. helpstring("Major OS Version (Raw data from OSVERSIONINFO)")]
  59. HRESULT MajorVer([out, retval] long *majorver);
  60. [propget,
  61. helpstring("Minor OS Version (Raw data from OSVERSIONINFO)")]
  62. HRESULT MinorVer([out, retval] long *minorver);
  63. [propget,
  64. helpstring("OS Build number (Raw data from OSVERSIONINFO)")]
  65. HRESULT BuildNum([out, retval] long *buildnum);
  66. [propget,
  67. helpstring("Returns true if the machine is running NT")]
  68. HRESULT PlatformIsNT([out, retval] VARIANT_BOOL *pfIsNT);
  69. [propget,
  70. helpstring("Returns any service pack string for OS")]
  71. HRESULT ServicePack([out, retval] BSTR *servicepack);
  72. [propget,
  73. helpstring("IConnectedMachine Major Version")]
  74. HRESULT HostMajorVer([out, retval] long *majorver);
  75. [propget,
  76. helpstring("IConnectedMachine Minor Version")]
  77. HRESULT HostMinorVer([out, retval] long *minorver);
  78. [propget,
  79. helpstring("Get status value by index.")]
  80. HRESULT StatusValue([in] long nIndex, [out, retval] long *pnStatus);
  81. }
  82. // This interface is not intended to ever be remoted or marshalled
  83. [uuid(854c316b-c854-4a77-b189-606859e4391b), dual, local]
  84. interface IGlobalMTScript : IDispatch
  85. {
  86. [propget,
  87. helpstring("MTScript Major Version")]
  88. HRESULT HostMajorVer([out, retval] long *majorver);
  89. [propget,
  90. helpstring("MTScript Minor Version")]
  91. HRESULT HostMinorVer([out, retval] long *minorver);
  92. [propget,
  93. helpstring("A place to store global data that is visible to other clients which connect to this machine")]
  94. HRESULT PublicData([out, retval] VARIANT *pvData);
  95. [propput]
  96. HRESULT PublicData([in] VARIANT vData);
  97. [propget,
  98. helpstring("A place to store global data that should not be made visible to clients which connect")]
  99. HRESULT PrivateData([out, retval] VARIANT *pvData);
  100. [propput]
  101. HRESULT PrivateData([in] VARIANT vData);
  102. [helpstring("Quits the MTScript process")]
  103. HRESULT ExitProcess();
  104. [helpstring("Shuts down all running scripts and restarts")]
  105. HRESULT Restart();
  106. [propget,
  107. helpstring("Returns the local machine's name")]
  108. HRESULT LocalMachine([out, retval] BSTR *pbstrName);
  109. [helpstring("Behaves similar to the C/C++ #include. Parses in the given script file.")]
  110. HRESULT Include(BSTR bstrPath);
  111. [helpstring("Execute script file in the same thread as the caller. Param is available to script as 'ScriptParam'.")]
  112. HRESULT CallScript(
  113. [in] BSTR Path,
  114. [optional, in] VARIANT *Param);
  115. [helpstring("Execute script file in a new thread. Param is available to script as 'ScriptParam'.")]
  116. HRESULT SpawnScript(
  117. [in] BSTR Path,
  118. [optional, in] VARIANT *Param);
  119. [propget,
  120. helpstring("Argument passed to 'CallScript' or 'SpawnScript'")]
  121. HRESULT ScriptParam(
  122. [out, retval] VARIANT *Param);
  123. [propget,
  124. helpstring("Returns the path of the scripts used by the script engine")]
  125. HRESULT ScriptPath([out, retval] BSTR *pbstrPath);
  126. [helpstring("Call external function in specified DLL")]
  127. HRESULT CallExternal([in] BSTR bstrDLLName,
  128. [in] BSTR bstrFunctionName,
  129. [in,optional] VARIANT *pParam,
  130. [out,retval] long *pdwRetVal);
  131. [helpstring("Resets multiple ThreadSyncs with the given name to non-signaled. On error, reset no ThreadSyncs.")]
  132. HRESULT ResetSync([in] const BSTR bstrName);
  133. [helpstring("Waits for a ThreadSync with the given name to be signaled")]
  134. HRESULT WaitForSync([in] BSTR bstrName, // Name of ThreadSync
  135. [in] long nTimeout, // Timeout in ms
  136. [out, retval] VARIANT_BOOL *pfSignaled); // TRUE if event was signaled, FALSE on timeout
  137. [helpstring("Waits for multiple ThreadSyncs with the given names to be signaled")]
  138. HRESULT WaitForMultipleSyncs([in] const BSTR bstrNameList, // Comma separated list of ThreadSync names
  139. [in] VARIANT_BOOL fWaitForAll, // If TRUE, all listed syncs must be signaled
  140. [in] long nTimeout, // Timeout in millisec
  141. [out, retval] long *plSignal); // Index of signaled ThreadSync. 0 if timed-out, 1 if fWaitForAll=true
  142. [helpstring("Sets the given (1 or more) ThreadSyncs to signaled. They stays signaled until ResetSync is called")]
  143. HRESULT SignalThreadSync([in] BSTR bstrName);
  144. [helpstring("Obtains a thread lock with the given name (a.k.a. critical section")]
  145. HRESULT TakeThreadLock([in] BSTR bstrName);
  146. [helpstring("Obtains a thread lock with the given name (a.k.a. critical section")]
  147. HRESULT ReleaseThreadLock([in] BSTR bstrName);
  148. [helpstring("Gives the script thread a chance to handle cross-thread communication")]
  149. HRESULT DoEvents();
  150. // BUGBUG -- Need to design better feedback/error UI
  151. [helpstring("Puts up a messagebox.")]
  152. HRESULT MessageBoxTimeout([in] BSTR bstrMessage, // Message Text
  153. [in] long cButtons, // Number of buttons (max 5)
  154. [in] BSTR bstrButtonText, // Comma separated list of button text. Number must match cButtons
  155. [in] long lTimeout, // Timeout in minutes. If zero then no timeout.
  156. [in] long lEventInterval, // Fire a OnMessageBoxInterval event every lEventInterval minutes
  157. [in] VARIANT_BOOL fCanCancel, // If TRUE then timeout can be canceled.
  158. [in] VARIANT_BOOL fConfirm, // If TRUE then confirm the button pushed before returning.
  159. [out, retval] long *plSelected); // Returns button pushed. 0=timeout, 1=Button1, 2=Button2, etc.
  160. [helpstring("Runs a command on the local machine")]
  161. HRESULT RunLocalCommand([in] BSTR bstrCommand, // Command to run (does not wrap it in a shell)
  162. [in] BSTR bstrDir, // Directory to use as working directory.
  163. [in, DEFAULTVALUE_("")] BSTR bstrTitle, // The window title to use (if bstrCommand invokes a shell)
  164. [in, DEFAULTVALUE_(0)] VARIANT_BOOL fMinimize, // If TRUE, the new process is started minimized
  165. [in, DEFAULTVALUE_(0)] VARIANT_BOOL fGetOutput, // If TRUE, capture STDOUT and STDERR and make available using GetProcessOutput()
  166. [in, DEFAULTVALUE_(-1)] VARIANT_BOOL fWait, // If TRUE, doesn't return until finished
  167. [in, DEFAULTVALUE_(-1)] VARIANT_BOOL fNoCrashPopup,// If TRUE, unhandled exceptions in the child process just terminate the process
  168. [in, DEFAULTVALUE_(0)] VARIANT_BOOL fNoEnviron, // If TRUE, invoke it with an empty environment
  169. [out, retval] long *plProcessID); // ID of new process, 0 on error.
  170. [helpstring("Returns the error code from RunLocalCommand if it failed")]
  171. HRESULT GetLastRunLocalError([out, retval] long *plErrorCode);
  172. [helpstring("Returns the STDOUT & STDERR data for the process up to this point")]
  173. HRESULT GetProcessOutput([in] long lProcessID,
  174. [out, retval] BSTR *pbstrData);
  175. [helpstring("Returs the exit code for the given process")]
  176. HRESULT GetProcessExitCode([in] long lProcessID, [out, retval] long *plExitCode);
  177. [helpstring("Terminates the given running process")]
  178. HRESULT TerminateProcess([in] long lProcessID); // Calls IScriptedProcessSink::RequestExit first if the process is connected
  179. [helpstring("Sends information to a process connected through IScriptedProcess")]
  180. HRESULT SendToProcess([in] long lProcessID,
  181. [in] BSTR bstrType,
  182. [in] BSTR bstrData,
  183. [out, retval] long *plReturn);
  184. [helpstring("Sends email using MAPI")]
  185. HRESULT SendMail([in] BSTR bstrTo, // To line, separated by spaces
  186. [in] BSTR bstrCC, // CC line, separated by spaces
  187. [in] BSTR bstrBCC, // BCC line, separated by spaces
  188. [in] BSTR bstrSubject,
  189. [in] BSTR bstrMessage,
  190. [in, DEFAULTVALUE_("")] BSTR bstrAttachmentPath,
  191. [in, DEFAULTVALUE_("")] BSTR bstrUsername, // Login username
  192. [in, DEFAULTVALUE_("")] BSTR bstrPassword, // Login password
  193. [out, retval] long *plErrorCode);
  194. [helpstring("Sends email using SMTP")]
  195. HRESULT SendSMTPMail([in] BSTR bstrFrom, // Sender - must be a valid address w/ domain. e.g. "[email protected]"
  196. [in] BSTR bstrTo, // To line, separated by spaces, must have domain
  197. [in] BSTR bstrCC, // CC line, separated by spaces, must have domain
  198. [in] BSTR bstrSubject,
  199. [in] BSTR bstrMessage,
  200. [in] BSTR bstrSMTPHost, // Name of SMTP Host to send mail through
  201. [out, retval] long *plErrorCode);
  202. [helpstring("If 'Assertion' = True then Assert with 'Message'.")]
  203. HRESULT ASSERT(
  204. [in] VARIANT_BOOL Assertion,
  205. [in] BSTR Message);
  206. [helpstring("Output 'Message' to debug console.")]
  207. HRESULT OUTPUTDEBUGSTRING(
  208. [in] BSTR Message);
  209. [helpstring("Uneval the string")]
  210. HRESULT UnevalString([in] BSTR bstrIn,
  211. [out, retval] BSTR *bstrOut);
  212. [helpstring("Copy or append one file to another. Return lastbytecopied+1")]
  213. HRESULT CopyOrAppendFile(
  214. [in] BSTR bstrSrc, // File to READ
  215. [in] BSTR bstrDst, // File to WRITE
  216. [in] long nSrcOffset, // Offset in READ file to start reading from
  217. [in] long nSrcLength, // Max # of bytes to READ (pass -1 to read to EOF)
  218. [in] VARIANT_BOOL fAppend, // If true, append to WRITE file, else always create WRITE file
  219. [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.
  220. [helpstring("Sleeps n milliseconds")]
  221. HRESULT Sleep([in] int nTimeout);
  222. [helpstring("Reboots the local machine")]
  223. HRESULT Reboot();
  224. [helpstring("Fires the OnScriptNotify event to any clients connected to us through the RemoteMTScript object")]
  225. HRESULT NotifyScript(BSTR bstrEvent, VARIANT vData);
  226. [helpstring("Registers the given object so that events can be hooked up")]
  227. HRESULT RegisterEventSource([in] IDispatch *pDisp, [in, DEFAULTVALUE_("")] BSTR bstrProgID);
  228. [helpstring("Unregisters an object registered with RegisterEventSource")]
  229. HRESULT UnregisterEventSource([in] IDispatch *pDisp);
  230. [propget,
  231. helpstring("Get status value by index.")]
  232. HRESULT StatusValue([in] long nIndex, [out, retval] long *pnStatus);
  233. [propput,
  234. helpstring("Get status value by index.")]
  235. HRESULT StatusValue([in] long nIndex, [in] long nStatus);
  236. }
  237. // ****************************************************************
  238. // EVENT INTERFACES
  239. // ****************************************************************
  240. [uuid(854c316a-c854-4a77-b189-606859e4391b)]
  241. dispinterface DLocalMTScriptEvents
  242. {
  243. properties:
  244. methods: // Events
  245. //
  246. //
  247. [helpstring("Main function called when script is loaded"),
  248. id(DISPID_MTScript_ScriptMain)] void ScriptMain();
  249. [helpstring("Fired when another machine connects to this machine through the RemoteMTScript object with the intent of controlling us"),
  250. id(DISPID_MTScript_OnMachineConnect)]
  251. void OnMachineConnect();
  252. [helpstring("Fired when a connected machines calls Exec()"),
  253. id(DISPID_MTScript_OnRemoteExec)]
  254. void OnRemoteExec([in] BSTR bstrCmd,
  255. [in] BSTR bstrParams,
  256. [out, retval] VARIANT *pvDataReturn);
  257. // This event is only fired on the thread that received the call to
  258. // RegisterEventSource for that object.
  259. [helpstring("Fired when the object fires an event"),
  260. id(DISPID_MTScript_OnEventSourceEvent)]
  261. void OnEventSourceEvent([in] IDispatch *pDisp,
  262. [in] long lDispid);
  263. // This event is only fired on the thread that called RunLocalCommand
  264. // for that process.
  265. [helpstring("Fired to give info on a process created with RunLocalCommand"),
  266. id(DISPID_MTScript_OnProcessEvent)]
  267. void OnProcessEvent([in] long lProcessID, // Process ID
  268. [in] BSTR bstrEvent, // String giving event name
  269. [in] VARIANT vData, // Data associated with the event
  270. [out, retval] long *plReturn); // Return value
  271. // This event is only fired on the script thread that made the call
  272. // to MessageBoxTimeout.
  273. [helpstring("Fired by MessageBoxTimeout() every specified number of minutes when timing out."),
  274. id(DISPID_MTScript_OnMessageBoxInterval)]
  275. void OnMessageBoxInterval();
  276. // This event is fired when a script error occurs.
  277. // A return value is expected.
  278. // If 0 is returned, mtscript.exe displays a dialog
  279. // If 1 is returned mtscript invokes the script debugger (if present)
  280. // else the error is ignored.
  281. // MTScript.exe always records the error via OUTPUTDEBUGSTRING.
  282. [helpstring("Invoked on script error"),
  283. id(DISPID_MTScript_OnScriptError)]
  284. void OnScriptError([in] BSTR bstrFile,
  285. [in] long nLine,
  286. [in] long nChar,
  287. [in] BSTR bstrText,
  288. [in] long sCode,
  289. [in] BSTR bstrSource,
  290. [in] BSTR bstrDescription,
  291. [out, retval] VARIANT *pvDataReturn);
  292. }
  293. [uuid(854c3170-c854-4a77-b189-606859e4391b)]
  294. dispinterface DRemoteMTScriptEvents
  295. {
  296. properties:
  297. methods: // Events
  298. //
  299. //
  300. [helpstring("Fired when a connected machine calls NotifyScript event"),
  301. id(DISPID_RemoteMTScript_OnScriptNotify)]
  302. void OnScriptNotify(BSTR bstrIdent, VARIANT vInfo);
  303. }
  304. // ****************************************************************
  305. // COCLASSES
  306. // ****************************************************************
  307. [uuid(854c316e-c854-4a77-b189-606859e4391b),
  308. noncreatable]
  309. coclass LocalMTScript
  310. {
  311. [default] interface IGlobalMTScript;
  312. [default, source] dispinterface DLocalMTScriptEvents;
  313. }
  314. [uuid(854c316d-c854-4a77-b189-606859e4391b)]
  315. coclass RemoteMTScript
  316. {
  317. [default] interface IConnectedMachine;
  318. [default, source] dispinterface DRemoteMTScriptEvents;
  319. }
  320. [uuid(854c3182-c854-4a77-b189-606859e4391b)]
  321. coclass RemoteMTScriptProxy
  322. {
  323. [default] interface IRemoteMTScriptProxy;
  324. [default, source] dispinterface DRemoteMTScriptEvents;
  325. }
  326. }