Link to home
Start Free TrialLog in
Avatar of ellandrd
ellandrdFlag for Ireland

asked on

use PHP to run .vbs file from command line

is the above possible?
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of ellandrd

ASKER

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
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
>>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$
ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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>
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...
Eek! Probably a permissions issue.

That's because of the msgbox. Remove that.
ok, btw
ive took out the msgbox code and it still hangs... ive tried on my workstation and on server and both hang...
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...
ive given test.vbs full permissions too
i dont seem to be able to run anything on the command line using PHP
What is the VB script going to do with the value? Do that in PHP.
my VBS file lists all the installed software on the users machine using an IP address.  its for an intranet application.

any other ideas/options?
can PHP run a BAT file?
still no working, so im just stick to ASP to see if i can get this working...