An Exec component for ASP Version 3.0 Sept 20, 1998
Copyright (c) 1997, 1998 by ServerObjects Inc.
All rights reserved.
http://www.serverobjects.com
Notes for version 1.0 & 2.0 users:
Please unregister the old version before installing this new version. You
can do this by typing regsvr32 /u aspexec.dll Also note that the object is
now called AspExec.Execute instead of ASPsvg.Execute so your Server.CreateObject
calls will need to be changed to reflect this new name.
Description:
ASPExec allows you to execute DOS and Windows apps. The following functionality
is available through ASPExec property
Installation:
To use this ASP component move the DLL into a subdirectory (like \winnt\system32
for NT or \windows\system for Win95) and type regsvr32 aspexec.dll You MUST
go into control panel/services/world wide web publishing service and turn
Allow Service to Interact with Desktop on to use this component if you run
IIS as a service. Some users after upgrading to SP3 report that visual apps
no longer pop up. Make sure that you have any Inetinfo managed services marked
as "Allow to Interact with Desktop" if you want to see visible apps on the
server screen. Otherwise they will appear as hidden windows.
Usage:
See the following example ASP scripts for usage
ASPCOPY.ASP
<html>
<head><title>ASPExec Test (copy)</title><head>
<body>
<H3>ASPExec Copy Test</H3>
<%
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd /c copy c:\*.* g:\temp"
Executor.Parameters = ""
strResult = Executor.ExecuteDosApp
Response.Write "<pre>" & strResult & "</pre>"
%>
</body>
</html>
ASPDIR.ASP
<html>
<head><title>ASPExec Dir Test (ping)</title><head>
<body>
<blockquote>
<H3>ASPExec Dir Test</H3>
<%
function Subst (strValue, strOldValue, strNewValue)
intLoc = InStr(strValue, strOldValue)
While intLoc > 0
if intLoc > 1 then
if intLoc = Len(strValue) then
strValue = Left(strValue, intLoc-1) & strNewValue
else
strValue = Left(strValue, intLoc -1) & strNewValue & Right(strValue, Len(strValue)-(intLoc-Len(strOldValue)+1))
end if
else
strValue = strNewValue & Right(strValue, Len(strValue)-1)
end if
intLoc = InStr(strValue, strOldValue)
Wend
Subst = strValue
end function
function FixUpItems (strItem)
if strItem <> "" then
strItem = Subst(strItem, "<", "<")
strItem = Subst(strItem, ">", ">")
FixUpItems = strItem
else
FixUpItems = "<br>"
end if
end function
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "cmd"
Executor.Parameters = "/C dir c:\"
strResult = FixUpItems(Executor.ExecuteDosApp)
Response.Write "<pre>" & strResult & "</pre>"
%>
</blockquote>
</body>
</html>
ASPEXEC.ASP
<html>
<head><title>ASPExec Test (ExecuteWinApp)</title><head>
<body bgcolor=white text=black>
<blockquote>
<H3>ASPExec ExecuteWinApp Test</H3>
<%
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "notepad.exe"
Executor.Parameters = "c:\autoexec.bat"
Executor.ShowWindow = True
Response.Write "Attempting to execute " & Executor.Application & "<br>"
strResult = Executor.ExecuteWinApp
Response.Write "The result of this call was: " & strResult
%>
<p>If you do not see Notepad then it is possible that Notepad is running with a hidden window.
This could be caused by not having "Allow Service to Interact with Desktop" turned off in
Control Panel/Services/World Wide Web Publishing Service or it could be that the version
of IIS you are running is preventing the window from being displayed. Look in a task list
such as task manager, or use TList from the NT resource kit to see if Notepad is running.
<B>Note: All InetInfo managed services must have "Allow Service to Interact with Desktop"
turned on to see visible apps.</b>
</blockquote>
</body>
</html>
ASPEXECW.ASP
<html>
<head><title>ASPExec Test (ExecuteWinAppAndWait)</title><head>
<body bgcolor=white text=black>
<H3>ASPExec ExecuteWinAppAndWait Test</H3>
<%
Set Executor = Server.CreateObject("ASPExec.Execute")
rem ***********************************************
rem * I'm not feeling very original tonight so
rem * let's just execute notepad and then close it
rem * out to verify the Wait portion works...
rem ***********************************************
Executor.Application = "notepad.exe"
Executor.Parameters = "c:\autoexec.bat"
Executor.TimeOut = 9000
Response.Write "Attempting to execute " & Executor.Application & "<br>"
rem results of this method are the results of GetLastError
intResult = Executor.ExecuteWinAppAndWait
if intResult = 0 then
Response.Write "Execution successful"
else
Response.Write "The result of this call was: " & intResult
end if
%>
</body>
</html>
ASPPING.ASP
<html>
<head><title>ASPExec Test (ping)</title><head>
<body>
<H3>ASPExec Ping Test</H3>
<% if Request.QueryString("host") = "" then %>
<form action="/scripts/aspping.asp" method=get>
Enter Host to Ping: <input type=text size=45 name=host value="localhost">
<input type="Submit">
</form>
<% else
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "ping"
Executor.Parameters = Request.QueryString("host")
strResult = Executor.ExecuteDosApp
Response.Write "<pre>" & strResult & "</pre>"
end if
%>
</body>
</html>
ASPTRACE.EXE
<html>
<head><title>ASPExec Test (tracert)</title><head>
<body>
<H3>ASPExec TraceRt Test</H3>
<% if Request.QueryString("host") = "" then %>
<form action="/scripts/asptrace.asp" method=get>
Enter Host to Ping: <input type=text size=45 name=host value="www.microsoft.com">
<input type="Submit">
</form>
<%
else
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "tracert"
Executor.Parameters = Request.QueryString("host")
strResult = Executor.ExecuteDosApp
Response.Write "<pre>" & strResult & "</pre>"
end if
%>
</body>
</html>
Interested: