Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: Execute a console exe from asp with VB script


Message #1 by "Sasi Vellolil" <sasiv@a...> on Thu, 21 Nov 2002 16:34:00
This is one method I saw on the net to call an exe from ASP:

-------------------------------------------------------------------
<%
Set server_shell = Server.CreateObject("wscript.shell")
server_shell.Run "%comspec% /c serial.exe"
%>

When this executes I get:
"The application failed to initialize properly(0xc000042). Click OK to 
terminate the program"

I need to actually actually pass 2 command line aguments and receive the
return value.

Can I do somethin like this? :
server_shell.Run "%comspec% /c serial.exe 1 456 > output.txt"

---------------------------------------------------------------------
I saw another method as follow:

'VBScript to execute exe from asp:
<%
  Const ForReading = 1
  sDir = "c:\test\debug" 
  set oShell = Server.CreateObject("Shell.Application")
  set oFolder = oShell.NameSpace(sDir)  

  ' oFile is a FolderItem

  set oFile = oFolder.ParseName ("serial.exe")
   response.write "Testing" & "<BR>"
   response.write oFile.Name & "<BR>"
   response.write oFile.IsFileSystem & "<BR>"
   response.write oFile.ModifyDate & "<BR>"
   response.write oFile.Size & "<BR>"
   response.write oFile.Type & "<BR>"
   response.write oFile.Path & "<BR>"
  oFile.InvokeVerb
%>

This gave me NO errors. The response.writes printed the file details 
correctly. But I am not sure if the serial.exe was executed or not.
Again,how do I pass the argumnts and receive the output
(serail.exe 1  456 > output.txt)in this case.
---------------------------------------------------------------------

Any help will be greatly appreciated.

Sasi

  Return to Index