Previous Topic: !! Command--Invoke Command or Child Process and Auto-capture Output (Cmdlet)Next Topic: ?? Command--Write Output in a List to stdout (Cmdlet)


! Command--Invoke Command or Child Process (Cmdlet)

Run an operating system command or start an application as child process. The output produced by the child process is written to the AutoShell console by default. Optionally, redirect the output to an AutoShell OSRedirect object.

The command has the following syntax:

! cmd [-output osRedirect]
cmd

Specifies a command to execute or application to run. Multiple commands can be concatenated using a && sequence. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code into parenthesis.

osRedirect

(Optional) Existing OSRedirect object to receive the output of the child process.

Default: ""

Examples

Display the version string of a Windows OS:

! ver

Display the version string of a Windows OS display current directory:

! ver && cd

Ping a system on the network and capture output:

out=new OSRedirect();
! ping 192.168.0.100 -output out
if(out.result()==0)
{
    ? out.output();
}
else
{
    ? "Ping failed"
}

See also:

OSRedirect Class

!! Command--Invoke Command or Child Process and Auto-capture Output (Cmdlet)