• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

use PHP to run .vbs file from command line

is the above possible?
0
ellandrd
Asked:
ellandrd
  • 13
  • 6
1 Solution
 
Richard QuadlingSenior Software DeverloperCommented:
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 DeverloperCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 DeverloperCommented:
Option Explicit

Dim StrComputer
strComputer = WScript.Arguments.Item(0)
msgbox(strComputer)
0
 
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 DeverloperCommented:
Eek! Probably a permissions issue.

0
 
Richard QuadlingSenior Software DeverloperCommented:
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 DeverloperCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 13
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now