GettingStarted
GettingStarted

Reputation: 7625

How to get an HTA application to accept command line arguments?

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

When I run my HTA application, I get:

arrCommands is undefined

I am trying to make an HTA app that accepts command line arguments (optional).

Upvotes: 4

Views: 1327

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200563

Your script section contains an Option Explicit statement. That makes defining variables before you can use them mandatory. Add a line Dim arrCommands, i to your procedure:

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

Upvotes: 5

Related Questions