私のバッチ ファイルでは、VBScript を呼び出して 3 つのパラメーターを渡しています。以下に示すように、パラメーターは「IPADDRESS」、「PicName」、および「Storage」です。
バッチファイル:
set Pathname="C:\User\username\locationOfFile
cd /d %Pathname%
cscript.exe C:\User\username\locationOfFile\myScript.vbs IPADDRESS PicName Storage
私の VB6 プログラムでは、パラメーター値が定義されています。
たとえば、IPADDRESS = "170.190.xxx.xxx" としましょう
バッチ ファイルを読み取って、VB6 フォーム内の宣言に基づいて IPADDRESS の値を使用する方法はありますか? 変数 IPADDRESS、PicName、および Storage は、VB6 プログラムが通信する外部アプリケーションに基づいて常に変化するため、バッチで静的に設定することはできません ( ....\myScript.vbs 170.190.xxx.xxx pic1 C:\保管所)
私のVBScriptは以下のとおりです。
Option explicit
if WScript.Arguments.Count <> 3 then
WScript.Echo "Missing parameters"
else
Dim imageMagick
Set imageMagick = CreateObject("ImageMagickObject.MagickImage.1")
Dim cam_add
Dim annotate
Dim filename
Dim cmd
Dim WshShell
Dim return
cam_add = """http://" & WScript.Arguments(0) &"/image"""
annotate = """" & WScript.Arguments(1) & " - """ '& Date
filename = """" & WScript.Arguments(2) & WScript.Arguments(1) & ".jpg"""
cmd = "convert " & cam_add & " -fill gold -pointsize 45 -gravity southwest -annotate 0x0+25+25 " & annotate & " -trim +repage -verbose " & filename
WScript.Echo cmd
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.CurrentDirectory = "C:\Program Files\ImageMagick-6.8.0-Q16\"
return = WshShell.Run(cmd)
end if
要約すると、バッチを次のように設定する必要があります。
cscript.exe C:\User\username\locationOfFile\myScript.vbs IPADDRESS PicName ストレージ
そのため、パラメータ値は、VB6 フォーム内で設定されている内容に従って使用できます。