Use WScript.Sleep() or replacement in mshta.exe one-liner


Use WScript.Sleep() or replacement in mshta.exe one-liner



I want to use WScript.Sleep() function with a mshta.exe one-liner from a batch (I don't want to write temporary files) but I receive a WScript undefined error.


WScript.Sleep()


mshta.exe


WScript undefined



As stated in this answer:



WScript is an object provided by the W|CScript.exe hosts; IExplorer or
MSHTA don't provide it (see here).



In Sleep routine for HTA scripts:


window.setTimeOut


window.ResizeTo


select


mshta



I don't know how to make a single answer of these work or if possible.



Inside a .js run by c/wscript it works perfectly. Is there a replacement or a way to reference this function for mshta.exe?


.js


mshta.exe





I found that question, but refers to .hta files and I don't see how the answers (that create sleep functions) can be adapted to a mshta "javascript: ...;close()" commands (one of them is .vbs actually). I add about this in the question.
– cdlvcdlv
Jun 29 at 9:55



.hta


mshta "javascript: ...;close()"


.vbs





mshta vbscript:Close(Execute("CreateObject(""WScript.Shell"").Run ""ping.exe 100.64.1.1 -n 1 -w 2000"",0,True")) Try this, but Windows Defender blocks it.
– langstrom
Jun 29 at 16:26


mshta vbscript:Close(Execute("CreateObject(""WScript.Shell"").Run ""ping.exe 100.64.1.1 -n 1 -w 2000"",0,True"))





It uses the ping method, but 100.64.1.1 is in a reserved space that should never actually ping (unlike 1.1.1.1 which was common before). The -w parameter is in milliseconds.
– langstrom
Jun 29 at 16:27


-w









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV