Is it possible to run a VBScript in UNIX environment?
Asked Answered
K

4

12

I've a Vbscript for merging excel sheet into a single workbook. I would like to know whether we could execute vbscript (.vbs) file in unix system. If yes, please help me with the procedures. Thanks in advance.

Kristoforo answered 2/12, 2013 at 19:5 Comment(1)
Even if you could, you wouldn't be able to run Excel.Rhotacism
W
13

Not sure about Unices, but on GNU/Linux it is possible to run VBScript using Wine, but VBScript support is limited.

On Debian/Ubuntu you can install as follows:

$ sudo apt-get install wine 
...
$ 

To run from command line:

$ wine cscript some-script.vbs

or

$ wine wscript some-script.vbs

For example I can run following script using Wine 1.7.19 from Ubuntu Wine PPA:

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

$ wine cscript test.vbs
fixme:vbscript:VBScript_SetScriptState unimplemented SCRIPTSTATE_INITIALIZED
fixme:scrrun:textstream_Close (0x13e208): stub
$ cat out.txt
Output to file test
$
Wilmerwilmette answered 4/6, 2014 at 22:30 Comment(1)
looks like this works now WScript.Echo "test"Km
L
3

You can install vbsedit on your windows box, use it to create and executable from the vbscript. You can then use Wine/PlayonLinux to run the executable code.

Learning answered 8/7, 2015 at 22:35 Comment(0)
S
2

The simple answer to your question is Yes we can run VBScript on UNIX. But you will not be able to run excel on it. Although even if you get Excel to run using WINE I dont know how it would link the COM objects in the Excel to VBScript .

One possible altenative could be to install OpenOffice on the *NIX box and then configure OpenOffice to save and create Excel Docs(but I am not very sure about this)

Scheld answered 2/12, 2013 at 19:7 Comment(2)
The COM object is in Excel, not in VBScript, and I'd like to see how you run a VBScript in Unix.Pearlene
@AnsgarWiechers:- Just updated my answer! Got a typo and yes using WINE it could be used. Although I agree that it is not possible to run it on UNIX directly.(Do correct me if I am missing something)Scheld
T
1

Use wine start /path/to/your/script/script.vbs.

Toshiatoshiko answered 27/3, 2019 at 13:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.