Interested in improving this site? Please check the To Do page.
sys.winShellCommand
New Windows-only verb for executing commands on the shell.
Syntax
sys.winShellCommand (s, adrExitCode=nil, adrStdErr=nil)
Params
s, a string, is the command to execute on the command line.
adrExitCode is an optional address that defaults to nil. If specified, the object pointed to will receive the exit status code of the command shell.
adrStdErr, an optional address that defaults to nil. If specified, the object pointed to will capture the stderr output of the command shell.
Actions
Launches the system command shell and executes the string s as if typed on the command line.
Returns
A string, the stdout output of the command shell.
Examples
sys.winShellCommand ("set path")
« "Path=C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\system32\\WBEM\r\n"
sys.winShellCommand ("type foobar", @exitCode, @stderr)
« ""
While this command itself did not write any data to stdout, exitCode was set to 1 indicating an error condition and stderr captured the error message “The system cannot find the file specified.\r\n”
Errors
If the system command shell can not be located, an error message will be generated.
Notes
This verb is new in Frontier 10.1a8. It is implemented only in the Windows version.
To determine the location of the command shell, this verb first examines the COMSPEC environment variable. If it is not defined or does not contain a valid file path, this verb attempts to guess the name of the system command shell and looks for it in all directories specified in the PATH environment variable. On Windows 95, Windows 98, and Windows ME, the shell is assumed to be named “command.com”, on all newer versions it is assumed to be named “cmd.exe”.
Errors generated by the shell when executing the command string will not cause a corresponding scriptError to be generated in Frontier. In order to determine whether the command was executed successfully, examine the value pointed to by adrExitCode on return. An error condition is conventionally indicated by a non-zero value. Additionally, an error message may be available as the value pointed to by adrStdErr.