在 VBcript 中使用换行符转换命令行



在Windows 7命令行上,我使用msg命令向远程PC发送消息,如下所示,工作正常:

msg * /servername:computer1 line1^
more?
more? line2

第一行末尾的回旋符(^)强制换行符,然后我按"回车"两次。结果是远程PC上带有2行的消息框。

如何让此命令在 VBScript 中像这样工作:

set wshshell = createobject("wscript.shell")
intreturn = wshshell.run("cmd /c msg.exe " & _
                         "/server:computer1 * line1^" & _
                         vbcrlf & "line2")

无需通过cmd或使用stin作为输入。

Set wso = CreateObject("WScript.Shell")
wso.run "msg.exe * line1" & VbCrLf & "line2", , False

它会像这样工作

最新更新