I'm doing a project with not enough time to rewrite what is written in HTA. I need to call a HTA using cmd.exe /C (so it closes the window after it formulates, generating a flashing hta box). I am able to do this in an invoke-expression fashion, but I'm trying to get it as a start-job with a mixture of variables.
$RunHTA = {
param(
[string]$FP, ### filepath to hta
[string]$output) ### output
Invoke-Expression -command 'cmd.exe /C $FP /H:`"$output`"' ### this line works alone. the /H is the save report feature and the double quotes are needed by the hta
}
$fp="C:\Path\To\HTA\file.hta"
$output = "C:\Output\path"
$j = Start-job $RunHTA -ArgumentList $FP,$output
$j | Receive-job
The filename, directory name, or volume label syntax is incorrect.
+ CategoryInfo : NotSpecified: (The filename, d...x is incorrect.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
I've done some testing and the variables are getting passed through correctly. Using returns to see the full variables.
Seems simple and probably something that should work without hassle.
Any ideas?