2
votes

I have VBS file with the only line

CreateObject("Wscript.Shell").Run "cmd /c start mshta.exe %cd%/app.hta",0,True

When I click this VBS file, there is a delay before the HTA file is opened, so I need to display some message during that time and hide it when HTA file is opened. It will be better if I would be able to stylize the window with the message.

How can I do it?

2
VBScript doesn't really provide means for parallel execution, even though there are workarounds for some scenarios. You could use the Popup method, but that's just based on a timer, so it won't react to whether the HTA is started or not. But why do you need the VBScript in the first place? You could just launch the HTA directly.Ansgar Wiechers
This HTA file is destined for different users and I noticed I can't open it directly on some computers without right-clicking, the "Open with..." command and finding mshta.exe inside of the Windows folder. So I need the file is being opened without these additional actions and VBS is the only way I've found at the moment.stckvrw
I would recommend fixing the configuration on those computers where directly launching a HTA doesn't work.Ansgar Wiechers
But that also mean additional actions I don't want to force users to do. It's better to try the Popup methodstckvrw
I don't think you should cater to users with broken configurations, but of course that's for you to decide.Ansgar Wiechers

2 Answers

1
votes

This will speed up starting the program. See no starting a program called cmd for no real purpose. No calling cmd's Start which starts program in unusual ways and slow by nature. Specifing it's path means it doesn't need to be searched for.

CreateObject("Wscript.Shell").Run "C:\windows\system32\mshta.exe ""%cd%\app.hta""",0,True
0
votes

An example of a message with the Popup method:

CreateObject("Wscript.Shell").Popup "Please wait...", 1, "Window tile"

1 is seconds to wait