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.

130 lines
5.7 KiB

  1. ********************** RunLocalCommand ***********************
  2. RunLocalCommand usage:
  3. If RunLocalCommand is called with fWait=true, the call will not return
  4. until the process has exited. The return value will be an identifier for
  5. the dead process that can be used in a call to GetProcessOutput() and
  6. GetProcessExitCode(). If the return value is zero,
  7. an error occurred and GetLastRunLocalError() can be called to get the
  8. error code. OnProcessEvent events will be fired for this process. The
  9. returned process ID is only valid until the next call to RunLocalCommand
  10. on that thread.
  11. If RunLocalCommand is called with fWait=false, the call returns
  12. immediately and the return code is the process identifier. If the ID is 0
  13. an error occurred which can be retrieved by calling
  14. GetLastRunLocalError(). The OnProcessEvent event will be fired to indicate
  15. events regarding the process, such as termination. See below for details.
  16. GetProcessExitCode() can be called for any process which has exited.
  17. Calling GetProcessExitCode() if the process is still running is an error.
  18. GetProcessOutput() can be called for any process which had
  19. fGetOutput=true. If fWait was true, then GetProcessOutput() will return
  20. all information written to STDOUT and STDERR while the process was
  21. running. If fWait was false, then if the process has terminated the
  22. return value is the same as if fWait was true. If the process is still
  23. running, all text sent to STDOUT & STDERR up to the current time will be
  24. returned.
  25. For a process which has connected via the IScriptedProcess interface (an
  26. OnProcessEvent event is fired when this happens) the script can call
  27. SendToProcess() to send information to that process. If the process is not
  28. connected a call to SendToProcess will be ignored and the return value is
  29. zero.
  30. OnProcessEvent events:
  31. When OnProcessEvent is fired, the first parameter (lProcessID) contains
  32. the ProcessID associated with the event, the second parameter (bstrEvent)
  33. is a string identifying the event, and the third parameter (vData) is data
  34. associated with the particular event.
  35. bstrEvent='exited': the process has exited and vData is the process exit
  36. code.
  37. bstrEvent='terminated': The process was terminated as a result of a call
  38. to TerminateProcess(). vData will have no data.
  39. bstrEvent='crash': The process or one of its children had an unhandled
  40. exception and was terminated. vData will have no data. (Win2000 only)
  41. bstrEvent='connected': Fired when the process connects to the script
  42. host through the IScriptedProcess interface.
  43. bstrEvent can also be any value set by the running process through the
  44. IScriptedProcess interface. By connecting to this interface, processes
  45. that are aware of the scripting engine can communicate to the script. In
  46. this case, bstrEvent will be an identifier string given by the process,
  47. and vData will contain a parameter string given by the process. The return
  48. value from the OnProcessEvent function is passed to the calling process.
  49. It must be an integer value.
  50. Implementation Notes:
  51. * Return 1 for the processId if fWait=true.
  52. * Return code and output info must be stored per-thread for PID=1.
  53. * Use Win2K's Job APIs to better manage terminating a process.
  54. * Pass an environment variable with a unique ID when creating a process.
  55. Processes should use this ID when calling IScriptedProcess::SetProcessID.
  56. (On win2K only this can be accomplished using the job APIs)
  57. ********************** Script Engine Interfaces ***********************
  58. The interface used for the global interface of the script engines is
  59. IGlobalMTScript. The script engines should use the PublicData and
  60. PrivateData properties on the global object to store data that must be
  61. shared between script engines. The PublicData property is made visible to
  62. an external COM object which can be created remotely. The intent of this
  63. is for the creation of a UI which can manipulate the scripts. The
  64. PrivateData property is for the storage of other global data which should
  65. not be made visible outside the script engine.
  66. ********************** MTScript Service ***********************
  67. The MTScript service is an EXE which runs as a service. When running, it
  68. registers the RemoteMTScript class as a remotable COM object. Any number
  69. of these objects can be created at a time and it allows a remote client
  70. to talk to the MTScript engine. The script engine runs even if no clients
  71. are connected.
  72. Issues:
  73. * Need a way to reset the script engine
  74. * Need a way to download scripts
  75. * Should support both JScript and VBScript
  76. ********************** UI Operation ***********************
  77. A UI to the MTScript engine is created by creating a web page which
  78. instantiates the RemoteMTScript class. This gives it access to the
  79. public data published by the script engine, which can be used to display
  80. status information and impact the build. There is also an Exec method on
  81. the COM object which fires an event on the primary script in the script
  82. engine. The script engine can then take appropriate action depending on
  83. the command.
  84. The RemoteMTScript class also has an event interface which is used to send
  85. notifications back to the web page.
  86. Issue: How does the returning event interface get hooked up? Can you hook
  87. up to events dynamically on an object created via script code?
  88. ********************** Controlling Remote Machines *******************
  89. A script can control remote machines by instantiating the RemoteMTScript
  90. COM object using the standard script mechanism ("new ActiveXObject(...)"
  91. in JScript). The remote machine becomes a slave to the machine which can
  92. then control it.
  93. Hooking up the events on the RemoteMTScript object is done using the
  94. standard JScript event hooking mechanism. If no such mechanism is
  95. available (is there?) then the IGlobalMTScript interface will provide a
  96. mechanism to register and unregister for events on the object.