?
Solved

PHP and VBS

Posted on 2011-03-01
5
Medium Priority
?
812 Views
Last Modified: 2012-05-11
Hi Experts,
We can use PHP exec command to call VBS code.
<?
$arg = 'anything';
exec ("csript script1.vbs $arg" );
?>

1.) How can I get return values of script1.vbs to PHP.
2.) From PHP can I call fn1 function which is inside script1.vbs

BR Dushan.
0
Comment
Question by:Dushan De Silva
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 35012578
Hi,

1)
I'm not that great with PHP, but I do know that VBScript is only capable of returning an integer value, through the use of
WScript.Quit(#)

However, it looks like you could obtain the output from the command by adding a parameter to the exec method:
http://php.net/manual/en/function.exec.php

So if your VBS had WScript.Echo statements in it, then the PHP array should hold that output.

2)
No, you cannot "include" any code in the page for global execution other than php.  If you want to use it, you'd need to convert it.

Regards,

Rob.
0
 
LVL 17

Author Comment

by:Dushan De Silva
ID: 35012673
Hi Rob,
Thanks a lot again!
1.) Fantastic!, I will use WScript.Echo and will capture it from PHP as array.
2.) Can I call VBS function from command line. (then I can try to execute that command using php exec or shell_exec)

BR Dushan.
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 2000 total points
ID: 35012908
1) Sure, hopefully it works.
2) I guess you could.  If you're VBS had something like this:

 
strFunction = WScript.Arguments.Item(0)

Execute "Call " & strFunction

Function MyFunction1
	WScript.Echo "Function1 was called."
End Function

Function MyFunction2
	WScript.Echo "Function2 was called."
End Function

Open in new window


and then you used this PHP:
$arg = 'Function1';
exec ("csript script1.vbs $arg",$arroutput,$returnvalue);

Then it should work (I think).

Regards,

Rob.
0
 
LVL 17

Author Closing Comment

by:Dushan De Silva
ID: 35013077
Yes, thanks lot!
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35013102
No worries.

Thanks for the grade,

Regards,

Rob.
0

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question