如何在批处理文件中运行 VBS 代码?

如何在批处理文件中运行 VBS 代码?

我知道该cscript "filename.VBS"命令,但我想在批处理文件中运行 VBS 代码,这样我就不必创建 VBS 文件来执行此操作。

这是我的VBS代码:

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

答案1

用一个混合 VBS 批处理脚本。将 VBS 部分放在<job><script>标签之间

<!-- : 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>

是否可以在批处理文件中嵌入并执行 VBScript 而不使用临时文件?

相关内容