duanchi19820419 2012-09-26 15:25
浏览 95
已采纳

32位PHP可以在64位IIS服务器上运行.vbs脚本吗?

There is a vbscript that we must run to consolidate information gathered in a custom web application into our management software. The .vbs is in the same folder as the web application which is built in CodeIgniter 2.

Here is the controller code:

public function saveToPM( $budgetType ){
    // run it 
    $obj = new COM( 'WScript.Shell' ); 

    if ( is_object ( $obj ) ) { 
        $obj->Run( 'cmd /C wscript.exe D:\pamtest\myload.vbs', 0, true );
        var_dump($obj->Run);
    } else { 
        echo 'can not create wshell object'; 
    } // end if

    $obj = null;

    //$this->load->view('goodPush');
} // end saveToPM function

We have enabled DCon in the php.ini file and used dcomcnfg to enable permissions for the user.

I borrowed the code from http://www.sitepoint.com/forums/showthread.php?505709-run-a-vbs-from-php.

The screen echos "Code executed" but the vbscript does not run.

We have been fighting with this for a while so any help is GREATLY appreciated.

  • 写回答

2条回答 默认 最新

  • duanraa1984 2012-09-27 06:47
    关注

    It's a bit messy. PHP calls WScript.Shell.Run which will call cmd (with /c - i.e terminate cmd.exe when it's done its thing) which will call cscript.exe to run and interpret a .vbs. As you can see quite a few things that have to go right! :)

    What if you 'wait' for the WScript.Shell.Run call to end (your $wait variable) before continuing execution of the wsh script which will in turn allow PHP to continue execution etc?

    Since you're not waiting for the call to finish, PHP thinks its all good and continues onto the next line (interpreted language).

    Also, maybe have the .vbs create an empty text file? Just so you have an indication that it has actually run.

    Just take a step back, have a beer and it'll come to you! Gogo troubleshoot!

    And - http://ss64.com/vb/run.html

    If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵