Option Explicit Dim wsh Dim runcmd Dim location Dim i ' https://stackoverflow.com/questions/20409056/automating-mouse-clicks-for-an-application set wsh = CreateObject("Wscript.Shell") With wsh 'WScript.echo WScript.Arguments.Item(0) ' Launch installer by using wshell to run: nonadmin.bat ' https://stackoverflow.com/questions/2469754/using-command-line-arguments-in-vbscript ' https://stackoverflow.com/questions/57614153/how-to-pass-two-arguments-to-cmd-via-wscript-shell ' https://ss64.com/vb/run.html runcmd = """..\scripts_and_patches\nonadmin.bat """ + WScript.Arguments.Item(0) 'wsh.run runcmd, 1, true wsh.run runcmd wscript.sleep 2000 ' need 3 enter presses, then type %GSDL3SRCHOME%\ext\DjVuLibre as install location ' then 2 enters, give it time for installation, 2 more enters ' https://www.vbsedit.com/html/4b032417-ebda-4d30-88a4-2b56c24affdd.asp 'wsh.sendkeys"{enter}{enter}{enter}" wsh.sendkeys"{enter 3}" ' Extra enter when djvu is already installed 'wsh.sendkeys"{enter}" 'Filepath field: Ctrl-a for select all, then delete existing contents of field wsh.sendkeys"^{a}" wsh.sendkeys"{DEL}" 'https://stackoverflow.com/questions/904739/can-i-pick-up-environment-variables-in-vbscript-wsh-script location = wsh.ExpandEnvironmentStrings("%GSDL3SRCHOME%\ext\DjVuLibre") ' Can't do wsh.sendkeys location because the textfield makes autocomplete suggestions for filepaths ' which hampers sending of keys as whole string part way. Typing chars individually is not a problem. ' https://stackoverflow.com/questions/1135826/get-each-character-in-a-string-using-vbscript ' Send the string too fast, and it drops some chars, so sleep at least 100 between each char ' https://superuser.com/questions/1363423/unexpected-behavior-in-vbscript-with-sendkeys For i=1 To Len(location) wsh.sendkeys Mid(location,i,1) WScript.Sleep 100 Next wsh.sendkeys"{ENTER 2}" ' Give installer 10 seconds (it appears to need far less) WScript.Sleep 10000 wsh.sendkeys"{ENTER 2}" WScript.Sleep 1000 ' Setting wsh=Nothing releases the object too early even with the extra sleep above ' See https://stackoverflow.com/questions/517006/is-there-a-need-to-set-objects-to-nothing ' use of With and End With following next link seems to help. Follows our doc2html.vbs ' https://stackoverflow.com/questions/20718029/sentry-objects-in-vba/20718181#20718181 'wsh = nothing End With