|
1.Command22 overview |
| All components included into the Command22 package are used for running the console
application or MS DOS commands from inside your application without bringing up the
command prompt (MS DOS) window. |
| The most frequent situation when the Command22 functionality may be more than helpful
is the case when you try to launch a command from your installation script
|
| (a good example may be a net start or net stop command) - when your installation
suddenly opens an ugly dos box and suddenly closes it, the user's impression can't be worse.
|
| Command22 provides the variety of possibilities for controlling input and output streams of
the console applications
|
|
2.Cmd22 ActiveX Control |
| The control displays a window containing two parts:
the upper part displays the current control status (i.e. Idle, Running, Waiting for User input, etc.),
command return code (if any) and appropriate graphics (application icon, animated X-clock, stop icon, etc.).
The bottom part of the window holds the command output data (the user input may be emulated
using the Input method) and the command output data:
|
| The whole content of this window or its part is available for calling application through the
SelectAll , Clear, Copy methods.
|
| The Cmd22 visual appearance is controlled by BgColor, FgInputColor and FgOutputColor properties.
The RunCommand method is used to launch a command.
|
| When the command is running, the calling application may be notified about the command execution process with the Cmd22 generated events.
|
| 2.1.Cmd22 Properties |
| 2.1.1.Visible |
| Returns or sets the visibility state of a Cmd22 control.
|
| Syntax: |
| object.Visible [ = value ]
|
| The Visible property
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| value |
Required. A boolean value corresponfding to the object visibility
(a value of false means "hidden")
|
|
| 2.1.2.BgColor |
| Returns or sets the background color of the control window
|
| Syntax: |
| object.BgColor [ = value]
|
| The BgColor property
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| value |
Required. An OLECOLOR RGB value for window background color |
|
| 2.1.3.FgInputColor |
| Returns or sets the text color for the command input in the control window |
| Syntax: |
| object.FgInputColor[ = value]
|
| The FgInputColor property
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| value |
Required. An OLECOLOR RGB value for input text color |
|
| 2.1.4.FgOutputColor |
| Returns or sets the text color for the command output in the control window |
| Syntax: |
| object.FgOutputColor[ = value]
|
| The FgOutputColor property
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| value |
Required. An OLECOLOR RGB value for command output text color |
|
| 2.1.5.RecentComandOutput |
| Returns command output |
| Syntax: |
| object.RecentComandOutput |
| The RecentComandOutput property
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
|
| Return values: |
| The RecentComandOutput property returns a string expression.
|
| Remarks: |
| This property is read-only and is not available at design time.
|
| Normally application uses this property while handling Cmd22 events
|
|
| 2.2.Cmd22 Methods |
| 2.2.1.RunCommand |
| Launches the command-line application and "gracefully" waits for the completion.
|
| Syntax: |
| object.RunCommand( command )
|
| The RunCommand method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| command |
Required. a string expression that indicates command |
|
| 2.2.2.Input |
| Emulates entering user data into command line prompt |
| Syntax: |
| object.Input( data )
|
| The Input method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| data |
Required. A string expression to be passed to the running application. Cmd22 automatically appends the CR/LF characters to the data string. |
|
| 2.2.3.Stop |
| Terminates command.
|
| Syntax: |
| object.Stop( )
|
| The Stop method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
|
| 2.2.4.SelectAll |
|
| Syntax: |
| object.SelectAll( )
|
| The SelectAll method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
|
| 2.2.5.Clear |
|
| Syntax: |
| object.Clear( )
|
| The Clear method
syntax has these parts:
|
|
|
| 2.2.6.Copy |
|
| Syntax: |
| object.Copy( )
|
| The Copy method
syntax has these parts:
|
|
|
| 2.2.7.IsSelectionEmpty |
|
| Syntax: |
| boolean object.IsSelectionEmpty( )
|
| The IsSelectionEmpty method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
|
| Return values: |
| IsSelectionEmpty method returns boolean value.
|
|
| 2.3.Cmd22 Events |
| 2.3.1.CmdEnded |
| Fires when the application launched with the RunCommand method terminates.
|
| Syntax: |
| Private Sub object_CmdEnded(ByVal RC As long)
|
| The CmdEnded event
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| RC |
the application return code |
|
| 2.3.2.CmdIdle |
| Fires when the application launched with the RunCommand enters the Idle state.
|
| Syntax: |
| Private Sub object_CmdIdle()
|
| The CmdIdle event
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
|
| 2.3.3.CmdOutput |
| Fires each time the command launched with the RunCommand method writes some data to the standard output device - either stdout or stderr.
The container may retreive the command Output using the RecentComandOutput property.
|
| Syntax: |
| Private Sub object_CmdOutput()
|
| The CmdOutput event
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
|
|
| 2.4.Cmd22 Example |
| The installation package includes TestCmd22 - a Visual C project
illustrating the Cmd22 usage in the MFC application.
|
|
|
|
|
|
3.Scmd22 COM object |
| SCMD22 supports a set of methods described below. Those methods can be accessed through theICmdRun interface.
The scmd22.h header and scmd22_i.c files from the Examples\Common subdirectory of the CMD22 installation directory contain the ICmdRun declaration and the SCMD22 class ID
and interface ID definitions.
|
| 3.1.SCMD22 methods |
| 3.1.1.RunCommand |
| Launches the command.
|
| Syntax: |
| C++ Syntax: |
| HRESULT RunCommand([in] VARIANT *Command, [in] VARIANT *WndTitle, [in] VARIANT *InputData,[in] long Flags,[out,retval] long *pProcId);
|
| Attention: if some of Command, WndTitle and InputData parameters has variant type other than VT_BSTR, SCMD22 assumes the "empty string" value for that parameter.
|
| JavaScript Syntax: |
| pProcId = object.RunCommand ( Command , WndTitle , InputData, Flags )
|
| The RunCommand method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| Command |
Required. a string expression that indicates command |
| WndTitle |
Required. a string expression that indicates window title |
| InputData |
Required. a string expression that indicates input data |
| Flags |
Required. Flags indicate if dialog appear and which buttons appear in the dialog:
1 - Hide dialog
2 - Show 'Abort' button
4 - Show 'Hide' button |
| pProcId |
Required. [out, retval] handle to the object |
|
| 3.1.2.WaitForProcess |
| Waits for process that was lanched by RunCommand method.
|
| Syntax: |
|
C++ Syntax: |
| HRESULT WaitForProcess([in] long ProcId) |
| JavaScript Syntax |
| object.WaitForProcess ( ProcId )
|
| The WaitForProcess method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| ProcId |
Required. Handle to the object retrieved by RunCommand method |
|
| 3.1.3.TerminateProcess |
| Terminates process that was lanched by RunCommand method.
|
| Syntax: |
| C++ Syntax: |
| HRESULT TerminateProcess([in] long ProcId) |
| JavaScript Syntax: |
| object.TerminateProcess( ProcId )
|
| The TerminateProcess method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| ProcId |
Required. Handle to the object retrieved by RunCommand method |
|
| 3.1.4.RunCommandAndWait |
| Launches the command and waits for the completion
|
| Syntax: |
|
C++ Syntax: |
| HRESULT RunCommandAndWait ([in] VARIANT *Command, [in] VARIANT *WndTitle, [in] VARIANT *InputData,[in] long Flags,[out,retval] long *pRCVal);
|
|
Attention: if some of Command, WndTitle and InputData parameters has variant type other than VT_BSTR, SCMD22 assumes the "empty string" value for that parameter.
|
|
JavaScript Syntax: |
| pProcId = object.RunCommandAndWait ( Command , WndTitle , InputData, Flags )
|
| The RunCommandAndWait method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| ProcId |
Required. Handle to the object retrieved by RunCommand method |
|
| Example: |
| var obj = new ActiveXObject("Scmd22.CmdRun"); |
| var pid = obj.RunCommandAndWait("ping.exe -n 20 127.0.0.1","Pinging LocalHost","",6);
|
|
|
|
4.DCMD22.DLL |
| DCMD22.DLL is a "pure" DLL inplementation of the SCMD22 COM object.
|
| This DLL was designed for usage from the InstallShield installation scripts, but it may
also be integrated with a C or C++ application.
|
| The functions exported from the DLL are described in the c22dll.h file included in the installation package.
|
| From the functional point of view they are identical to the SCMD22 object methods:
|
| 4.1.DCMD22 methods |
| 4.1.1.C22RunCommand |
| Launches the command.
|
| Syntax: |
| C++ Syntax: |
| HRESULT RunCommand([in] VARIANT *Command, [in] VARIANT *WndTitle, [in] VARIANT *InputData,[in] long Flags,[out,retval] long *pProcId);
|
| Attention: if some of Command, WndTitle and InputData parameters has variant type other than VT_BSTR, SCMD22 assumes the "empty string" value for that parameter.
|
| JavaScript Syntax: |
| pProcId = object.RunCommand ( Command , WndTitle , InputData, Flags ) |
| The C22RunCommand method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| Command |
Required. a string expression that indicates command |
| WndTitle |
Required. a string expression that indicates window title |
| InputData |
Required. a string expression that indicates input data |
| Flags |
Required. Flags indicate if dialog appear and which buttons appear in the dialog:
1 - Hide dialog
2 - Show 'Abort' button
4 - Show 'Hide' button |
| pProcId |
Required. [out, retval] handle to the object |
|
| 4.1.2.C22WaitForProcess |
| Waits for process that was lanched by RunCommand method.
|
| Syntax: |
|
C++ Syntax: |
| HRESULT WaitForProcess([in] long ProcId) |
| JavaScript Syntax: |
| object.WaitForProcess ( ProcId ) |
| The C22WaitForProcess method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| ProcId |
Required. Handle to the object retrieved by RunCommand method |
|
| 4.1.3.C22TerminateProcess |
| Terminates process that was lanched by RunCommand method.
|
| Syntax: |
|
C++ Syntax: |
| HRESULT TerminateProcess([in] long ProcId) |
| JavaScript Syntax |
| object.TerminateProcess( ProcId )
|
| The C22TerminateProcess method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| ProcId |
Required. Handle to the object retrieved by RunCommand method |
|
| 4.1.4.C22RunCommandAndWait |
| Launches the command and waits for the completion
|
| Syntax: |
|
C++ Syntax: |
| HRESULT RunCommandAndWait ([in] VARIANT *Command, [in] VARIANT *WndTitle, [in] VARIANT *InputData,[in] long Flags,[out,retval] long *pRCVal);
|
|
Attention: if some of Command, WndTitle and InputData parameters has variant type other than VT_BSTR, SCMD22 assumes the "empty string" value for that parameter.
|
|
JavaScript Syntax: |
| pProcId = object.RunCommandAndWait ( Command , WndTitle , InputData, Flags )
|
| The C22RunCommandAndWait method
syntax has these parts:
|
| Part |
Description |
| object |
Required. An object expression that evaluates to the Cmd22 object |
| ProcId |
Required. Handle to the object retrieved by RunCommand method |
|
| Example: |
| var obj = new ActiveXObject("Scmd22.CmdRun"); |
| var pid = obj.RunCommandAndWait("ping.exe -n 20 127.0.0.1","Pinging LocalHost","",6);
|
|
|
|
5.Input redirection restrictions |
| The current Command22 version redirects only stdin console application input.
|
| If console application reads data from some other logical device, Command22 will
not be able to handle this kind of input.
|
|
6.Redistribution of Command22 components |
| If you are still in your trial period, you may run CMD22 executables only on the system they were originally
installed.
|
| Once you have purchased and registered your CMD22 copy, you may freely redistribute it.
|
| You need to supply with our application only relevant parts of the "core" CMD22:
i.e. if you don't use, say, SCMD22 - you don't need to ship it.
|
| CMD22.DLL and SCMD22.DLL are self-registering objects, you must register and unregister them
in the installation of your product either using REGSVR32.EXE or directly calling DllRegisterServer and DllUnregisterServer functions.
|
| No registration required for DCMD22.DLL.
|