8.5.24 SetStandardFile or SetStdFile (set the standard input, output, or error file)
- Purpose
-
Opens and sets the standard input, standard output, or standard error file for processes called by the Exec command.
In JP1/Script 07-50 or later, the command supports large files.
- Syntax
SetStandardFile (FilePath, Type [, Mode]) SetStdFile (FilePath, Type [, Mode])
- Arguments
-
- FilePath
-
Write the full path of the file to be set, using a character string or a variable that stores this value.
- Type
-
Specify the file type as one of the following values:
Value
Meaning
StdInput
Standard input
StdOutput
Standard output
StdError
Standard error
- Mode
-
If you specified StdOutput or StdError in Type, specify the creation mode as one of the following values:
Value
Meaning
Create
Create a new file.
Append
Add data to the existing file.
This value is optional. If you omit this value, Append is assumed.
This value is invalid if you specified StdInput in Type.
- Description
-
The SetStandardFile or SetStdFile command opens and sets the standard input, standard output, or standard error file for processes called subsequently by the Exec command. The command returns True on successful execution, or False if an error occurs.
The set files remain effective and open until execution of the ResetStandardFile command.
The files set by this command cannot be accessed by the NetExec command.
- Notes
-
-
Take care when specifying a file in the folder set in the environment variable ProgramFiles (normally the Program Files folder on the system drive) or WinDir (normally the Windows folder on the system drive). For details, see 1.8.2 Command behavior.
-
You can configure access permissions when creating a file you are setting. In the following registry key, set the access permissions beforehand:
- Registry key
-
HKEY_LOCAL_MACHINE\SOFTWARE\Hitachi\JP1/Script\SPTX\Option
- Value name
-
SecurityAttributesSucceed
- Value datatype
-
REG_DWORD
- Value
-
0: Access permissions are not set.
1: Access permissions are set to "Inherit access permissions from parent folders".
2: Access permissions are set to "Everyone: Full control".
If no value is set, or a value other than those above is set, the setting defaults to 0.
- When the setting takes effect
-
The setting takes effect the next time the script file is executed.
-
- Note
-
If any of the standard files (standard input, standard output, or standard error) is specified, processes executed by the Exec command may not execute normally. If this occurs, prepare empty files, and specify all three standard files (standard input, standard output, and standard error).
- Example
' When Backup.BAT is executed, write standard output in ' BatOut.TXT, and write standard error output in BatErr.TXT. SetStandardFile (_SCF_+"BatOut.TXT", StdOutput, Create) SetStandardFile (_SCF_+"BatErr.TXT", StdError) If Exec (_SCF_+"Backup.BAT", True) Then MessageBox ("Exec command succeeded.") Else MessageBox ("Exec command failed.") End ResetStandardFile ( StdOutput ) ResetStandardFile ( StdError )
- JP1/Script version
-
Supported from JP1/Script 05-10.