如何使用经典asp执行bat文件

问题描述 投票:0回答:1

任何人都可以用我的密码帮助我。我需要在经典ASP中执行。bat文件。下面是我的代码。

已经将我的IIS,应用程序池>身份>的设置更改为LocalSystem,代码正在工作。且没有错误,但是它无法执行test.bat

   <%

   dim fs,tfile,loc,locadd,loctime1,nameFile,wshell

   locadd = Month(Date)&Day(Date)&Year(Date)
   loctime1 =  stripNonNumeric(FormatDateTime(Now,3))
   nameFile = "\\85new\Accts85new\Texting\Reply\Karing\"
   loc = "\\85new\Accts85new\Texting\Reply\Karing\"&locadd&"_"&loctime1&".txt"
   set fs=Server.CreateObject("Scripting.FileSystemObject")
   set tfile=fs.CreateTextFile(loc)
   set wshell = Server.CreateObject("WScript.Shell") 

    For Each Item in Request.QueryString
        tfile.Write Item &";"& Request.QueryString(Item)&"$&$"
    next

    tfile.close
    set tfile=nothing
    set fs=nothing

    wshell.Run "C:\inetpub\wwwroot\Texting\test.bat"
    set wshell = nothing

    Function stripNonNumeric(inputString)
        Set regEx = New RegExp
         regEx.Global = True
         regEx.Pattern = "\D"
         stripNonNumeric = regEx.Replace(inputString,"")
      End Function
    %>

谢谢你,我是这个领域的新手,我读了很多书,但仍然没有执行我的test.bat

file batch-file asp-classic execute
1个回答
0
投票

使用此:

set wshell = CreateObject("WScript.Shell") 
wshell.run "c:\path\to\file.bat"

尝试创建这样的对象。

© www.soinside.com 2019 - 2024. All rights reserved.