如何让HTA应用程序接受命令行参数?

时间:2015-09-15 19:56:29

标签: vbscript hta

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            BorderPane root = new BorderPane();
            root.setSnapToPixel(true);
            Scene scene = new Scene(root,400,400);

            Line line = new Line();
            Line line2 = new Line();

            line.setStartX(0.0f);
            line.setEndX(100f);
            line.setStartY(30f);
            line.setEndY(30f);
            line.setStrokeWidth(1f);
            line.setStrokeType(StrokeType.OUTSIDE);
            line.setStroke(Color.BLACK);

            line2.setStartX(50.0f);
            line2.setEndX(200f);
            line2.setStartY(100f);
            line2.setEndY(100f);
            line2.setStrokeWidth(1f);
            line2.setStrokeType(StrokeType.OUTSIDE);
            line2.setStroke(Color.BLACK);

            root.getChildren().addAll(line, line2);

            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

当我运行我的HTA应用程序时,我得到“arrCommands未定义”。

我正在尝试制作一个accepts command line arguments(可选)的HTA应用。

1 个答案:

答案 0 :(得分:2)

您的脚本部分包含Option Explicit语句。这使得在强制使用它们之前定义变量。在您的程序中添加一行Dim arrCommands, i

Sub Window_onLoad
    Dim arrCommands, i
    arrCommands = Split(ITTool.commandLine, chr(34))
    For i = 3 to (Ubound(arrCommands) - 1) Step 2
        MsgBox arrCommands(i)
    Next
End Sub