douxian7808 2014-01-18 11:14
浏览 68

如何使用php执行vbscript

i have a VBScript file. When its on the computer it works fine. I want to put it on a php site for it to be executed by a button click. but i have not been successful.i have a VBScript file. When its on the computer it works fine. I want to put it on a php site for it to be executed by a button click. but i have not been successful.

Here is the code :

Const ForReading = 1
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\AppServ\www\abcd\testFile.txt", ForReading)
TheFile =   f.ReadAll

myArray = Split(theFile,vbcrlf)

for i = 0 to Ubound(MyArray)
Next

txt=Space(1)

Set myShell = CreateObject("WScript.Shell")
    myShell.run "cmd"
    WScript.Sleep 100

    myShell.SendKeys"telnet 192.168.1.1"
    myShell.SendKeys("{Enter}")
    WScript.Sleep 1500

    myShell.SendKeys"myname"
    myShell.SendKeys("{Enter}")
    WScript.Sleep 1500


    myShell.SendKeys"mypassword"
    myShell.SendKeys("{Enter}")
    WScript.Sleep 1500

    myShell.SendKeys"sudo -i"
    myShell.SendKeys("{Enter}")
    WScript.Sleep 1000

    myShell.SendKeys"su - zimbra"
    myShell.SendKeys("{Enter}")
    WScript.Sleep 1000  

    myShell.SendKeys"zmprov ma " & myArray(0) & " zimbraAccountStatus locked"
    myShell.SendKeys("{Enter}")
    WScript.Sleep 1000

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douzhang8033 2014-01-18 11:27
    关注

    PHP cant execute vbscript. If you want php to execute any other language, you have to write some kind of parser/interpreter which do this for you...

    But in your case, it should be easier to translate the script simply to php. A telnet client isn't that hard to implement. A simple example is found here: telnet connection using PHP

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建