外部プログラムの実行


  標準出力と標準エラー出力の取得



標準出力は、コンソールアプリケーションが、コマンドラインプロンプトに出力する場所です。以下のようにしてファイルに出力する事ができます

  
zip.exe -h > stdout.txt
  

Copyright (C) 1990-1999 Info-ZIP
Type 'zip "-L"' for software license.
Zip 2.3 (November 29th 1999). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -!   use privileges (if granted) to obtain all aspects of WinNT security
  -R   PKZIP recursion (see manual)
  -$   include volume label         -S   include system and hidden files
  -e   encrypt                      -n   don't compress these suffixes

標準エラー出力は、コンソールアプリケーションが、コマンドラインプロンプトに出力するエラー用の場所です。以下のようにして標準出力と同時にファイルに出力する事ができます

  
zip.exe -h > stdout.txt 2> stderr.txt
  

上記では、stderr.txt は空です。zip.exe にエラーを起こさせると違いがわかります

zip.exe - > stdout.txt 2> stderr.txt

この処理を非同期処理で実行すると、標準出力と標準エラー出力から文字列を取得する事ができます
( cmd.exe /c で実行する必要があります )

  
Call WshShell.Run( "cmd.exe /c zip.exe -h > stdout.txt 2> stderr.txt", 0, True )

strStd = "データはありません" : strErr = strStd
Set Handle = Fso.OpenTextFile( "stdout.txt", 1 )
if not Handle.AtEndOfStream then
	strStd = Handle.ReadAll
end if
Handle.Close
MsgBox(strStd)

Set Handle = Fso.OpenTextFile( "stderr.txt", 1 )
if not Handle.AtEndOfStream then
	strErr = Handle.ReadAll
end if
Handle.Close
MsgBox(strErr)
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ