+ -
当前位置:首页 → 问答吧 → ASP调用CMD的运行问题

ASP调用CMD的运行问题

时间:2011-11-30

来源:互联网

我写的CMD命令如下:
D:\UserIIS\wwwroot\SysAdm\SysRar\cmd.exe /c cd D:&cd D:\UserIIS\wwwroot&D:\UserIIS\wwwroot\SysAdm\SysRar\Rar.exe c -zReadMe.txt ydrc.rar
我用鼠标点“开始--》运行”粘贴以上命令(共一行),运行没有任何问题
可是我在ASP里面调用时,发现运行不正常(提示成功,实则没有运行),
我想应该不是权限问题,因为我的ASP调用CMD已经可以压缩文件了,我这儿只是想在压缩文件上添加一个注释
我的ASP代码如下:
Server.ScriptTimeout=99999
Dim winrar,cmddir
Winrar=Server.Mappath("/SysAdm/SysRar/Rar.exe") '压缩文件(Winrar)的地址
cmddir=Server.Mappath("/SysAdm/SysRar/cmd.exe") 'cmd.exe(命令提示符)的地址

Set Shell = Server.CreateObject("WScript.Shell")
  vvv=cmddir&" /c cd "&Left(server.mappath("/"),2)&"&cd "&server.mappath("/")&"&"&Winrar&" c -zReadMe.txt ydrc.rar"
  Response.write vvv & "<hr>"
Runcode = Shell.Run(vvv,0,true)
Runing = Shell.Run(cmddir&" /c taskkill /im winrar.exe",1,false)
Runing = Shell.Run(cmddir&" /c exit",1,false)
Set Shell=Nothing
if not isempty(Runcode) and Runcode=0 Then 
Response.Write("操作成功执行")
elseif not isempty(Runcode) then 
Response.Write("操作执行失败")
else
end If

作者: yncxlb   发布时间: 2011-11-30

以下命令通过用鼠标点“开始--》运行”,输入以下命令能正常运行:
D:\UserIIS\wwwroot\SysAdm\SysRar\cmd.exe /c D:\UserIIS\wwwroot\SysAdm\SysRar\Rar.exe c -zD:\UserIIS\wwwroot\ReadMe.txt D:\UserIIS\wwwroot\ydrc.rar
修改以上代码,提示操作为失败:
VBScript code

<%
    Server.ScriptTimeout=99999
    Dim winrar,cmddir
    Winrar=Server.Mappath("/SysAdm/SysRar/Rar.exe") 'Rar的地址
    cmddir=Server.Mappath("/SysAdm/SysRar/cmd.exe") 'cmd的地址
    Set Shell = Server.CreateObject("WScript.Shell")
        vvv=cmddir&" /c "&Winrar&" c -z"&server.mappath("/")&"\ReadMe.txt "&server.mappath("/")&"\ydrc.rar"
    Runcode = Shell.Run(vvv,0,true)
        Response.write vvv & "<hr>"
    Runing = Shell.Run(cmddir&" /c taskkill /im Rar.exe",1,false)
    Runing = Shell.Run(cmddir&" /c exit",1,false)
    Set Shell=Nothing
    if not isempty(Runcode) and Runcode=0 Then 
        Response.Write("操作成功执行")
    elseif not isempty(Runcode) then 
        Response.Write("操作执行失败")
    else
    end If
%>

作者: yncxlb   发布时间: 2011-11-30