View Full Version : Executing a batchfile with asp
Noodles24
08-18-2005, 03:08 PM
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
Cyberlord
08-18-2005, 03:40 PM
Hello,
try this:
<%
Set fso = Server.CreateObject("scripting.FileSystemObject")
Set objWsh = Server.CreateObject("Wscript.Shell")
objWsh.Run("D:\ASP\test2.bat", 1, True)
%>
or you use ASPExec:
<%
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
Noodles24
08-18-2005, 03:56 PM
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")
Cyberlord
08-18-2005, 04:06 PM
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
Noodles24
08-18-2005, 04:56 PM
Thanks for that, working fine now
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.