none
W10 HTA run HTA RRS feed

  • Question

  • Hello,

    With W10 you don't run HTA code from HTA code ?

    The Run command of ("WScript.Shell") don't work.

    Dim WS, Command, HtaFile
    HtaFile = "D:\A391062\@From C\@Essai Code\VBS\Hta\@heure boot\heureboot.hta"
    Set WS = CreateObject("WScript.Shell")
    Command = "Mshta.exe " & HtaFile                    '''' Same thing for Command = Htafile
    WS.Run Command, 1, True

    Strange... and Why...

    Thanks,

    Thierry.

    Wednesday, May 2, 2018 4:55 PM

Answers

  • It can't find the file because you didn't enclose it in quotes for the Run method's command line. In other words, you need to write this:


    Command = "Mshta.exe """ & HtaFile & """"
    

    If you don't quote the filename, the WshShell object's Run method is not parsing the command as you are expecting.


    -- Bill Stewart [Bill_Stewart]


    Thursday, May 3, 2018 1:29 PM
    Moderator

All replies

  • What's the error you get when you try that?

    -- Bill Stewart [Bill_Stewart]

    Wednesday, May 2, 2018 5:49 PM
    Moderator
  • Hello Bill

    If Command = "Mshta.exe & Htafile ==> a new default window with nothing on it

    If Command =  Htafile ==> The specified file is not found

    Thierry.

    Thursday, May 3, 2018 6:10 AM
  • Remove the "@" from you folder names.

    You can launch an HTA file without using MSHTA.


    \_(ツ)_/


    • Edited by jrv Thursday, May 3, 2018 7:07 AM
    Thursday, May 3, 2018 7:07 AM
  • In Windows 10 this doesn't work.  Perhaps there are new security restrictions.

    \_(ツ)_/

    Thursday, May 3, 2018 7:24 AM
  • Hello,

    It's works without characters "@" and "space" into folder names.

    Strange ?

    But thanks for your answer.

    Thierry.

    Thursday, May 3, 2018 8:11 AM
  • HTA uses an older API which does not support many characters. 

    HTAs are obsolete and should not be used if at all possible.  Use PowerShell and Windows Forms or plain HTML.


    \_(ツ)_/

    Thursday, May 3, 2018 9:09 AM
  • It can't find the file because you didn't enclose it in quotes for the Run method's command line. In other words, you need to write this:


    Command = "Mshta.exe """ & HtaFile & """"
    

    If you don't quote the filename, the WshShell object's Run method is not parsing the command as you are expecting.


    -- Bill Stewart [Bill_Stewart]


    Thursday, May 3, 2018 1:29 PM
    Moderator