我有两个经典的ASP页面,在其中必须调用批处理脚本。第一个正在工作:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%'Roda o arquivo BAT para chamada do script powershell
Set wshell = CreateObject("WScript.Shell")
wshell.Run "\\w102xnk172\c$\inetpub\wwwroot\DCT_NEW\App\copy_items.bat"
Set wshell = Nothing
'Cria o arquivo .txt de bloqueio, que o script powershell excluirá em sua finalização.
Dim fs,tfile
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set tfile = fs.CreateTextFile("\\w102xnk172\c$\inetpub\wwwroot\DCT_NEW\DB\running_script.txt")
tfile.Close
Set tfile = Nothing
Set fs = Nothing
'Quando não existir mais o arquivo, a interface continua.
filename = "running_script.txt"
path_db = "\\w102xnk172\c$\inetpub\wwwroot\DCT_NEW\DB\"
path_file = "\\w102xnk172\c$\inetpub\wwwroot\DCT_NEW\DB\running_script.txt"
Set fs = Server.CreateObject("Scripting.FileSystemObject")
While fs.FileExists(path_file) = True
Wend
%>
此代码运行我的脚本并创建一个“ running_script.txt”,然后检查它是否仍然退出,因此直到结束为止,任何代码都不会运行。最后,我的脚本删除了该文件。这样工作正常,另一个就很简单:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
page = REQUEST.QUERYSTRING("page")
If page = "ofs" Then
Set wshell = CreateObject("WScript.Shell")
wshell.Run "C:/www/gppintranet/scripts/ofs.bat"
Set wshell = Nothing
End If
response.Redirect("/gppintranet/view/home.asp")
%>
但是由于某种原因,它没有调用我的脚本。我会自动重定向到主页。我已经调试,它进入了我的If
语句,并且脚本运行正常。
我正在IIS 10.0.15063.0中运行此应用程序(如果有用)。 怎么了?我看不出它们之间有什么区别。
编辑:我已经在正常工作的环境下运行了非正常工作的脚本,但在该环境下也无法正常运行。我已经检查了两个IIS的版本和设置相同。工作脚本为:
@echo off
start "" http://w102xkj172/DCT_MASTER/update_dct_p2p.asp
timeout /T 5
echo Waiting for P2P DCT's information update...
:verify_locked
if exist \\w102xkj172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT_MASTER\p2p_running.txt (
goto :verify_locked
) else (
echo Copying files...
robocopy /IS \\w102xkj172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT\DB\ \\w102xnk172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT_LINE_P\DB\ DCT.mdb
robocopy /IS \\w102xkj172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT\DB\ \\w102xnk172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT_LINE\DB\ DCT.mdb
robocopy /IS \\w102xkj172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT\DB\ \\w102xnk172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT_LINE_1\DB\ DCT.mdb
robocopy /IS \\w102xkj172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT\DB\ \\w102xnk172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT_LINE_3\DB\ DCT.mdb
robocopy /IS \\w102xkj172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT\DB\ \\w102xnk172\c$\inetpub\wwwroot\PC_REPORTS\exemplo\DCT_LINE_4\DB\ DCT.mdb
)
exit
无效的是:
@echo off
START "" http://example.aspx