powershellcmdhtapsexec

Executing an HTA Application via PSEXEC with command line arguments


I have an .hta application that accepts two command line arguments. Executing the application on the remote machine via command line works just like the following

(command line - cmd)Example:

C:\Users\<user>\Desktop>MSI-BUILDER.hta "MSI_APP" "D:\APP\15.9.98"

But when using my desktop trying to execute the same command on the remote machine via PSEXEC I see the application running in task manager but nothing happens.

The first steps were assigning the command line arguments to variables in PowerShell:

$arg1 = "MSI_APP"
$arg2 = "D:\APP\15.9.98"

and executing this command in PowerShell fails (no errors, just hangs):

.\psexec -s -i \\Srv2012 cmd /c "start /i "MSI-BUILDER" "C:\Users\<user>\Desktop\MSI-BUILDER.hta" $arg1 $arg2"

The application launches just in task manager and I'm assuming in the background but I don't see any changes, so it might just be hanging...

Im not 100% sure if my syntax in this matter is correct for launching an HTA via powershell with command-line arguments.

Also is there a way or switch that I can actually see the application launch and do its thing after remotely executing the code, for testing purposes?


Solution

  • Okay so finally after hours of trying different things this is the command that worked for me

    Edited Command:

    .\PSEXEC -accepteula -s -i 2 \\SERVER cmd /c "D:\path\toapp\app.hta" $arg1 $arg2 -u username -p password