是否可以在 UNIX 环境中运行 VBScript?

aru*_*hen 10 unix vbscript scripting scheduling execution

我有一个 Vbscript,用于将 Excel 工作表合并到一个工作簿中。我想知道我们是否可以在unix系统中执行vbscript(.vbs)文件。如果是,请帮我办理手续。提前致谢。

rut*_*sky 10

不确定 Unices,但在 GNU/Linux 上可以使用Wine运行 VBScript,但VBScript 支持是有限的

在 Debian/Ubuntu 上,您可以按如下方式安装:

$ sudo apt-get install wine 
...
$ 
Run Code Online (Sandbox Code Playgroud)

从命令行运行

$ wine cscript some-script.vbs
Run Code Online (Sandbox Code Playgroud)

或者

$ wine wscript some-script.vbs
Run Code Online (Sandbox Code Playgroud)

例如,我可以使用来自Ubuntu Wine PPA 的Wine 1.7.19 运行以下脚本:

' test.vbs

'WScript.Echo "Echo test"  ' doesn't work

'MsgBox "Message box!"     ' look like doesn't work either

' Write to file - works
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("out.txt", True)
objFile.Write "Output to file test" & vbCrLf
objFile.Close
Run Code Online (Sandbox Code Playgroud)

跑:

$ wine cscript test.vbs
fixme:vbscript:VBScript_SetScriptState unimplemented SCRIPTSTATE_INITIALIZED
fixme:scrrun:textstream_Close (0x13e208): stub
$ cat out.txt
Output to file test
$
Run Code Online (Sandbox Code Playgroud)