1

我有一个经典的 ASP 页面,它需要访问通过 PHP 脚本生成的文件。是否可以从 VBScript 中以某种方式调用 PHP 脚本?

在有人问之前,我没有时间移植任何一个脚本。它们都非常复杂,我现在只需要一个短期解决方案。

现在下面没有生成错误,但是没有生成文件。我准备放弃了。

str = "D:\TTnav_Alpha\Alpha\Framework\EnvMgr\generate_jira_list.php"
Set objShell = CreateObject("WScript.Shell")
'response.write(str)
objShell.Run """C:\Program Files (x86)\PHP\php.exe"" " & str ,3,true
Set objShell = Nothing
4

2 回答 2

1

我的 .vbs 代码成功调用了 .php 文件中的脚本。

在我的 .vbs 文件中,我有这个:

set wshell = CreateObject("WScript.Shell")
wshell.Run "C:\xampp\php\php.exe -f C:\Temp\test2.php"
set wshell = nothing

如果路径中有空格,则必须用双引号将路径括起来,例如:

set wshell = CreateObject("WScript.Shell")
wshell.Run """C:\my xampp dir\php\php.exe"" " & "-f C:\Temp\test2.php"
set wshell = nothing 
于 2017-02-20T15:30:49.000 回答
0

Just invoke WScript.Shell as explained at How do I execute a DOS command / batch file / exe from ASP?

<% 
' Untested
set wshell = CreateObject("WScript.Shell") 
wshell.run "c:\dos\php c:\site\script.php" 
set wshell = nothing 
%>

Edit: You are now trying to execute this:

C:\Program Files (x86)\PHP\php.exeD:\TTnav_Alpha\Alpha\Framework\EnvMgr\generate_jira_list.php

This is an invalid command (if you copy it to a command prompt, it won't run). You need to quote the paths with spaces and separate the command from the argument:

"C:\Program Files (x86)\PHP\php.exe" D:\TTnav_Alpha\Alpha\Framework\EnvMgr\generate_jira_list.php

In VBScript you escape quotes doubling them so you want:

objShell.Run """C:\Program Files (x86)\PHP\php.exe"" " & str,3,false

By the way, that 3 means Activates the window and displays it as a maximized window. Don't forget to remove it before going live.

Ref: Run Method (Windows Script Host)

于 2013-10-08T14:31:26.063 回答