delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/03/19/18:15:33

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <47E19E70.FB4F9C29@dessent.net>
Date: Wed, 19 Mar 2008 16:14:56 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: invoke vbscript from cygwin?
References: <943be0b10803191523g2bba03cck7e17832dc56958ca AT mail DOT gmail DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Dave Burns wrote:

> How would one invoke a vbscript from cygwin, if it is possible? I
> guess invoking cygwin from a vbscript would also do the trick, though
> I'd rather not have to fiddle with the vbscript at all.

You invoke it the same way you would from a Windows command prompt, i.e.
cscript.exe or wscript.exe.

$ echo 'MsgBox ("Hello World!")' > foo.vbs

$ cscript //nologo foo.vbs

As far as "invoking Cygwin from a vbscript", that is too vague.  Cygwin
is not an abstract entity, it's a bunch of programs.  If you want to
invoke one of them it's no different than invoking any other program --
you have a command and some arguments and you run it.  If you want to
run more than a simple command you probably need to involve the shell
with -c, e.g. 

$ cat <<EOF >foo.vbs
Set x = WScript.CreateObject("WScript.Shell")
Set y = x.Exec("c:\cygwin\bin\bash -c 'echo hello world from bash'")
WScript.StdOut.Write(y.StdOut.ReadAll())
EOF

$ cscript //nologo foo.vbs
hello world from bash

Just like with anything you need to either add the Cygwin bin directory
to the PATH, set the working dir to the bin directory, or specify the
full pathname to the .exe.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019