Jan
Jan

Reputation: 361

How can I start an HTA application from R?

I want to start an HTA application from R but can not manage to.

I tried system2("test.hta") as well as system2("mshta test.hta") and system2("cmd /c test.hta").

This always gives me a message like Warning message: running command '"mshta test.hta"' had status 127.

Running the same HTA from a cmd command line works fine using the command lines test.hta or cmd /c test.hta. On the other hand mshta test.hta does not work although I would expect it to work.

Any ideas where the problem is or how I could manage to call my HTA from R?

(I am running R 3.2.2 on Windows 7 Professional)

Upvotes: 3

Views: 125

Answers (1)

John Coleman
John Coleman

Reputation: 51998

Use shell() rather than system2(). The latter is expecting an executable (.exe or .com) or batch file (.bat). This restriction isn't given in the help file for system2() but is in the help file for system(), for which system2() is an interface.

Make sure to include the full path to the HTA.

Upvotes: 3

Related Questions