在 Windows 批处理文件中嵌入 VBScript [英] Embed VBScript inside Windows batch file

查看:21
本文介绍了在 Windows 批处理文件中嵌入 VBScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在批处理文件中嵌入 VBScript?

Is it possible to embed VBScript within a batch file?

我目前有一个 .CMD 文件,它使用 .VBS 文件调用

I currently have a .CMD file that calls a .VBS file using

cscript //NoLogo MyScript.vbs

但我更愿意只分发一个 .CMD 文件.

but I'd prefer to distribute just a single .CMD file.

编辑:有一个类似的问题,其中包含有关如何在根本不生成中间文件的情况下执行此操作的答案:是否可以在不使用临时文件的情况下在批处理文件中嵌入和执行 VBScript?

EDIT: There is a similar question with answers on how to do this without generating an intermediate file at all: Is it possible to embed and execute VBScript within a batch file without using a temporary file?

推荐答案

http://www.computerhope.com/forum/index.php?topic=103686.0

@echo off
echo This is batch
:wscript.echo "This VBScript"
:wscript.echo "Today is " & day(date) & "-" & month(date) & "-" & year(date)
findstr "^:" "%~sf0">temp.vbs & cscript //nologo temp.vbs & del temp.vbs
echo This is batch again

这篇关于在 Windows 批处理文件中嵌入 VBScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆