Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Location
    UK
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Executing a batchfile with asp

    Hi,

    I'm new to asp, but am wanting to execute a batch file via a webpage and display it's output

    Can anyone tell me how to do this?

    Thanks

  • #2
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    try this:

    Code:
    <% 
    Set fso = Server.CreateObject("scripting.FileSystemObject")
    
    Set objWsh = Server.CreateObject("Wscript.Shell")
    objWsh.Run("D:\ASP\test2.bat", 1, True)
    
    %>
    or you use ASPExec:

    Code:
    <%
      Set objExec = Server.CreateObject("ASPExec.Execute")
      objExec.Application = "c:\aspexec.bat"
      objExec.ShowWindow = false
      strResult = objExec.ExecuteDosApp
      Response.Write "Result:<br>" & Replace(strResult, vbCrLf, "<br>")
      Set objExec = Nothing
    %>
    cheers

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Location
    UK
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    unfortunately I get this error when I do the first one:

    error '80070002'

    on this line:
    objWsh.Run "C:\WEB\DDC LIVE\updatecvs.bat", 1, True

    And when I do the second one I get this:

    Server object error 'ASP 0177 : 800401f3'

    Server.CreateObject Failed

    on this line:
    Set objExec = Server.CreateObject("ASPExec.Execute")

  • #4
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For the second example you need the free component "ASPExec" installed on your server.

    You can download it here:
    http://www.serverobjects.com/products.htm#free

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Location
    UK
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for that, working fine now


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •