SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast gazman99's Avatar
    Join Date
    May 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    run a .vbs from php

    hi all,

    i have vbscript (.vbs) file that i need to run from a php webpage. But how do i call and run the .vbs file?????

    i need to pass variables to the script as it initiates. Locally i use wshell or a windows shortcut to run the file but am stuck how to call and run it from php and i dont really wanna use .asp.

    Any ideas????


  2. #2
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use PHP COM, everything that wshell can do, can be done via PHP's COM object access!

    PHP Code:
    <?php

    /* command to run */

    $command 'wscript.exe C:/path_to/vbs_file.vbs argument_one argument_two';

    /*
     * wait for command to return a exit code?
     *
     * true = waits for the command to complete, before continuing this script
     * false = executes command then continues this script without waiting for command to exit
     *
    */

    $wait false;


    // run it

    $obj = new COM 'WScript.Shell' );

    if ( 
    is_object $obj ) )
    {
        
    $obj->Run 'cmd /C ' $command0$wait );
    }
    else
    {
        echo 
    'can not create wshell object';
    }

    $obj null;

    ?>

  3. #3
    SitePoint Enthusiast gazman99's Avatar
    Join Date
    May 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that printf

    does this run on the webserver??? -- as it going to be creating files on webserver

  4. #4
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, if the server is on a windows box that includes (IIS, Apache, Sambar, Sun ONE, Netscape, Merak) and few other, I don't remember all of them, but if PHP can run on the server, then local COM access via PHP will be available too! Remote access is also available if DCOM is active for that object. Java Also has a DCOM connector for Linux that allows you to run remote or local non-registry binding COM objects in PHP, under Linux too.

  5. #5
    SitePoint Enthusiast gazman99's Avatar
    Join Date
    May 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers bigman

  6. #6
    SitePoint Enthusiast gazman99's Avatar
    Join Date
    May 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ive tried working with that but it keeps returning the

    exception 'com_exception' with message 'Source: Unknown
    Description: Unknown' in C:\Inetpub\wwwroot\virtual-directories\clearest\public\ppt\uploadppt.php:33 Stack trace: #0 C:\Inetpub\wwwroot\virtual-directories\clearest\public\ppt\uploadppt.php(33): com->Run('wscript.exe C:\...', 0, false) #1 {main}
    any ideas what.....???

  7. #7
    SitePoint Enthusiast gazman99's Avatar
    Join Date
    May 2007
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you need to adjust the php.ini for this to work properly??


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •