dongliang7545 2019-03-18 14:47
浏览 130

使用exec()启动myFile.bat不起作用,但使用命令行[duplicate]运行

This question already has an answer here:

I am developing a web interface that will take care of changing colors in several Excel files.

For this, I try to run a .bat script that launches a .vbs script. I do all this server side (on an intranet machine so total access) that I configured with wamp (Apache 2.4.37 and PHP 7.2.14).

The problem is that the php page does not execute the script and run the browser in a infinite loop. My line for the script:

exec ('launch_vbs.bat');

I tried :

  • with system () and passthru (), no change.

  • to put the whole way, no change.

  • to specify chmod to 777 on my launch_vbs.bat file, no change

  • to add 2> & 1 at the end, no change.

  • to launch my file launch_vbs.bat in command line on the server, everything is done correctly, it modifies the colors of my excel files

  • to launch the php page containing the exec () in the command prompt of my server, the exec () is done correctly and the colors are modified in excels

My .bat and .vbs files (and even .php) are all in the same directory in the wamp server folder (C:/wamp64/www/MyProject/)

In short, I hold a little and I do not know what to do ... If anyone has an idea it would be great!

Thank you in advance !

</div>
  • 写回答

1条回答 默认 最新

  • dpx49470 2019-03-18 14:53
    关注

    Did you try to actually give the exact same command that you give in cmd like:

    exec('start launch_vbs.bat');
    

    Or using system:

      system('cmd /c launch_vbs.bat');
    

    note that cmd is the one running inside system32 of windows. That means that if you replace cmd with "C:\Windows\System32\cmd.exe" it should work as well. Source!!!

    Edit:

    Your bat file should trigger the execution of your vbs script. So it should look similar to:

    @echo off 
    start C:\wamp64\www\ODR\change_color.vbs
    
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程