Jump to content

[SOLVED] Run .VBS from PHP


ptolomea

Recommended Posts

First off I have done a search for this and there were actually 3 posts dealing with something along the same lines as me.  But there were no responses, the posters did not list enough of their code to see if they had something different that I have yet to try.

 

Here goes.

 

I am trying to run a .vbs script from php. I do not need the output of this script as the sole purpose of the website I am building is to run this script for a file.

 

The vbs script works flawlessly if I run cscript maintest.vbs from a command prompt

 

here is the code for the .php

<?PHP
$runCommand = "C:\\ISOStuff\\mount.vbs";
$wshshell = new COM("WScript.Shell");
$wshshell->Run($runCommand);
?>

 

now I have tryed all of the items below with and with out cscript in front.

shell_exec() with the vbs file and a baseline test for what the vbs file is sposed to do.(Open a file with test permamiters that the vbs script is able to get)

system() only the vbs file. this one i get a responce on the page but its just the first line of the cscript.

exec()

 

just to help here is the vbs file to

set wshshell = wscript.createobject("wscript.shell")
Set objEnv = WshShell.Environment("User")
iso = objEnv("mountediso")


wshshell.run "C:\isostuff\daemon.exe -unmount 0"
wshshell.run "C:\isostuff\daemon.exe -mount 0, " & iso

 

in the enviorment user section i have created a variable called mountediso and it holds C:\random.iso

and random.iso is a small file i created that has a window pop up on autorun so i can quickly tell if the procedure worked.

 

I am using wamp5 server (package of mysql4.1, apache2.2 and php5.2.2(CLI), and just because I saw another post on here about it, i have enabled the apache servers to allow interaction with desktop in services then rebooted

 

Any help is apreciated

Link to comment
Share on other sites

well through playing around with the environmental scope of my scripts I figured out a way to run a vbscript and do what the vbscript was doing through php

 

the biggest issue was that the items i was trying to run were not in the www directory on my server.

 

here is the solution code

<?PHP
//system("cscript mount.vbs")
exec("isostuff\daemon.exe -mount 0, isostuff\random.iso");
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.