Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling an exe file or batch file inside an asp page

Status
Not open for further replies.

sqlnerd

Programmer
Jan 21, 2003
24
IN
Hi,

Is it possible to call an exe file or a batch file from an asp page? Can anybody help me.

Thanx in advance...

SQLNerd
 
Bullschmidt,

Thanks for your suggestion. That link showed me a glimpse of the expected answer. But, when i ran that code, nothing happened in the browser. I provided a response.write and that got displayed. The batch file i wanted to run didnt run at all. Infact, i provided all permissions to the IUSER_ account in the folder where i ran the batch file. Also, IIS has been configured to execute scripts and executables.

what could be wrong?

SQLNerd
 
Hi I use this to run cacls

<%
dim Folder
Folder = &quot;C:\Inetpub\ & session(&quot;HomeDir&quot;)

run(&quot;cacls &quot;&quot;&quot; & Folder & &quot;&quot;&quot; /E /G &quot;&quot;&quot; & session(&quot;HomeDir&quot;) & &quot;&quot;&quot;:F /C /T&quot;)
run(&quot;cacls &quot;&quot;&quot; & Folder & &quot;&quot;&quot; /E /R Everyone /C /T&quot;)
Response.Redirect &quot;../frame.asp&quot;

function Run (command)
dim oShell, oFileSystem, strTempFile, strCommand
set oFileSystem = CreateObject(&quot;Scripting.FileSystemObject&quot;)
if (Err.Number) then
Run = &quot;Error creating object Scripting.FileSystemObject - &quot; & Err.Number & &quot; - &quot; & Err.Description
exit function
end if
strTempFile = oFileSystem.GetSpecialFolder(2) & &quot;\&quot; & oFileSystem.GetTempName()
set oShell = CreateObject(&quot;WScript.Shell&quot;)
if (Err.Number) then
Run = &quot;Error creating object WScript.Shell - &quot; & Err.Number & &quot; - &quot; & Err.Description
exit function
end if
strCommand = &quot;CMD /C &quot;&quot;&quot; & command & &quot; 1> &quot; & strTempFile & &quot; 2>&1&quot;&quot;&quot;
call oShell.Run(strCommand, 1, true)
if (oFileSystem.FileExists(strTempFile)) then
dim oFile
set oFile = oFileSystem.GetFile(strTempFile)
if (oFile.Size) then
dim oText
set oText = oFileSystem.OpenTextFile(strTempFile, 1, false)
Run = oText.ReadAll
oText.Close
set oText = nothing
else
Run = &quot;Failed to redirect command output.&quot;
end if
set oFile = nothing
else
Run = &quot;Failed to redirect command output.&quot;
end if
set oFileSystem = nothing
set oShell = nothing
end function
%>

It's in its own folder and run as an administrator(Change IIS)

Might help

Cheers
 
And here are some more links that might help:

4GuysFromRolla.com : ASP FAQS : The Nature of Things
Question: How can I call an executable program from my ASP page? by Bill Wilkinson - 10/17/2000

Executing Applications on a Server Through an ASP Page
Example: Getting Latest Versions From VSS [Micorsoft Visual Source Safe] by Neema Moraveji - 7/21/1999

How to Ping Using ASP by Bart Silverstein - 10/29/1998



Best regards,
J. Paul Schmidt
- Freelance ASP Web Developer
- ASP Design Tips
 
Thanks a lot! I will try all your suggestions.

SQLNerd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top