Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run a VBScript in UNIX environment?

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.

like image 542
arunpandiyarajhen Avatar asked Dec 02 '13 19:12

arunpandiyarajhen


People also ask

Can you run VBScript in Linux?

You can run VBScript on Linux...

How do you run a VBScript?

Click the Start button, and then click Run. In the Open field, type the full path of the script, and then click OK. You can also type WScript followed by the full name and path of the script you want to run.

What are the environment supported by VBScript language?

VBScript currently runs on below mentioned environments:Internet Information Server (IIS) – It is a Microsoft web server. Windows Script Host(WSH) – It is a native hosting environment of Windows operating system. Internet Explorer (IE) – It is the simplest hosting environment where we can run VBScript code.

Can you run VBScript in CMD?

If you want to execute a VBScript in the command prompt, you can use cscript.exe. See an example below. You can use Wscript. Echo in the VBScript in order to print information that will be displayed in the command prompt.


3 Answers

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
$
like image 80
rutsky Avatar answered Oct 15 '22 03:10

rutsky


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

like image 26
Ráfagan Avatar answered Oct 15 '22 02:10

Ráfagan


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)

like image 25
Rahul Tripathi Avatar answered Oct 15 '22 02:10

Rahul Tripathi