use PHP to run .vbs file from command line

is the above possible?
LVL 16
ellandrdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Richard QuadlingSenior Software DeveloperCommented:
Hi ellandrd,


If you can run the vbs script from the cli WITHOUT having to provide a program to run it ...

c:\>test.vbs 1.2.3.4

and that works, then ...

<?php
exec('test.vbs 1.2.3.4');
?>

should work.

Regards,

Richard Quadling.
0
 
ellandrdAuthor Commented:
for some reason, i cannot get anything to work for work either in PHP or ASP... and im getting pi*sed off now as i need to get this the .vbs file to run somehow
0
 
Richard QuadlingSenior Software DeveloperCommented:
Ok.

Go to the command line.

CD to the directory containing your test.vbs

type

test 1.2.3.4

What happens?

Does it work?

Do you have to type

test.vbs 1.2.3.4

Or do you have to type

cscript test.vbs 1.2.3.4
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
ellandrdAuthor Commented:
>>Go to the command line.
>>CD to the directory containing your test.vbs
>>type
>>test 1.2.3.4
>>What happens?

I get line 4, invalid charactor.


test.vbs
=================

Option Explicit

Dim StrComputer
strComputer = Command$
0
 
Richard QuadlingSenior Software DeveloperCommented:
Option Explicit

Dim StrComputer
strComputer = WScript.Arguments.Item(0)
msgbox(strComputer)
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
ellandrdAuthor Commented:
C:\Inetpub\wwwroot>cscript test.vbs 192.168.0.79
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Inetpub\wwwroot\test.vbs(92, 3) Microsoft VBScript runtime error: The remote server machine does not exist or is unavailable: 'GetObject'


C:\Inetpub\wwwroot>
0
 
ellandrdAuthor Commented:
OK.

i used an IP address that doe exist and it worked fine.

i have now tried:

echo (shell_exec("test.vbs 192.168.0.2" )) ? "worked" : "failed";

and PHP page just hangs...
0
 
Richard QuadlingSenior Software DeveloperCommented:
Eek! Probably a permissions issue.

0
 
Richard QuadlingSenior Software DeveloperCommented:
That's because of the msgbox. Remove that.
0
 
ellandrdAuthor Commented:
ok, btw
0
 
ellandrdAuthor Commented:
ive took out the msgbox code and it still hangs... ive tried on my workstation and on server and both hang...
0
 
ellandrdAuthor Commented:
do i have to use the full path ?

like:

shell_exec("C:\Inetpub\wwwroot\test.vbs 192.168.0.2" );

i have also tried:

exec("C:\Inetpub\wwwroot\test.vbs 192.168.0.2" );

still no go...
0
 
ellandrdAuthor Commented:
ive given test.vbs full permissions too
0
 
ellandrdAuthor Commented:
i dont seem to be able to run anything on the command line using PHP
0
 
Richard QuadlingSenior Software DeveloperCommented:
What is the VB script going to do with the value? Do that in PHP.
0
 
ellandrdAuthor Commented:
my VBS file lists all the installed software on the users machine using an IP address.  its for an intranet application.

0
 
ellandrdAuthor Commented:
any other ideas/options?
0
 
ellandrdAuthor Commented:
can PHP run a BAT file?
0
 
ellandrdAuthor Commented:
still no working, so im just stick to ASP to see if i can get this working...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.