2

I know the cscript "filename.VBS" command, but I want to run VBS code within a batch file so I will not have to make a VBS file to do it.

This is my VBS code:

sub Loading
    do while brw.busy
        wscript.sleep 350
    loop
end sub

query=inputbox("Please Enter What You Would Like To Search:","Multi-Engine Internet Searcher")
'down-Google
set brw=CreateObject("InternetExplorer.Application")
brw.navigate "https://www.google.ca/#q=" & (query)
brw.toolbar=false
brw.statusbar=true
brw.height=650
brw.width=950
brw.left=0
brw.top=0
brw.resizable=true
Call Loading
brw.visible=true
'up-google
'down-bing
3
  • Echo this code into %temp%\filename.VBS (random name recommended, or check this file not exists, do not forget to delete it after), then execute using start /w.
    – Akina
    Dec 24, 2019 at 6:43
  • 1
    Why not do it all in PowerShell? Apr 24, 2020 at 0:58
  • With all due respect Why not do it with batch script
    – user1123951
    Dec 11, 2020 at 18:04

1 Answer 1

4

Use a hybrid VBS-batch script. Put your VBS part between the <job><script> tags

<!-- : Begin batch script
@echo off
cscript //nologo "%~f0?.wsf" %1
exit /b

----- Begin wsf script --->
<job><script language="VBScript">
sub Loading
    do while brw.busy
        wscript.sleep 350
    loop
end sub

query=inputbox("Please Enter What You Would Like To Search:","Multi-Engine Internet Searcher")
'down-Google
set brw=CreateObject("InternetExplorer.Application")
brw.navigate "https://www.google.ca/#q=" & (query)
brw.toolbar=false
brw.statusbar=true
brw.height=650
brw.width=950
brw.left=0
brw.top=0
brw.resizable=true
Call Loading
brw.visible=true
'up-google
'down-bing
</script></job>

See Is it possible to embed and execute VBScript within a batch file without using a temporary file?

You must log in to answer this question.