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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP FileSystemObject?

Status
Not open for further replies.
Jul 13, 2003
25
US
I want to be able to run a batch file on my web server on the click of a button from a user. Can this be done, and what is the code?

I found something like what I have below to open a txt file, but I want it to work with a batch file instead.

<%
Set fs=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)

Set f=fs.OpenTextFile(&quot;c:\test.txt&quot;)
Response.Write(f.ReadAll)

f.Close

Set f=Nothing
Set fs=Nothing
%>

Thanks.
 
you can run a .bat file with the shell statement. remember that permissions etc.. must be set accordingly
example

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
Hey, thanks. The first one you gave me worked exactly like I wanted. I'll look at the others to see if I can take it further (if needed).

Now, how can I delay a Response.redirect about 5 seconds?
 
delay a redirect...

that's odd, but if you really wanted to I would loop it to a estimated 5 seconds. however that may get gittery on the serer. Why not do it client side with the setTimeInterval or something javascript style. That is pretty much what the language is for.



1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
Ok, let me explain what I am doing. I have a batch file that executes a macro within my access 2000 database. The macro outputs my query to a .snp file for web reports. When the user clicks &quot;Get Report&quot;, it executes the batch file that runs the macro, then redirects them to the specified page.

I want a delay in the redirect so the user will see the recently generated page.

Do you have a better way for me to do this? I'm no ASP programmer, but need to get this done.

Thanks for your help.
 
It is &quot;working&quot;, but I am having a bit of a problem. When the ASP code runs, it is not closing the process on the web server. It is leaving CMD.EXE and MSACCESS.EXE processes running, and not closing them. Then, when the script runs again, it starts a new process of each one.

Here is my code. Any ideas???
---------------------
<%
Shell &quot;c:\Reports.bat&quot;
%>

<%
Private Sub Shell(byVal command)
dim wshShell, boolErr, strErrDesc
On Error Resume Next
Set wshShell = CreateObject(&quot;WScript.Shell&quot;)
wshShell.Run command
if Err Then
boolErr = True
strErrDesc = Err.Description
end if
Set wshShell = Nothing
On Error GoTo 0
if boolErr then Err.Raise 5105, &quot;Shell Statement&quot;, strErrDesc
End Sub

Shell = nothing
%>
 
This is the batch file I am running. The Access macro is set to Quit and Save at the end.

Batch File
--------------------
&quot;C:\Program Files\Microsoft Office\Office\MSACCESS.EXE&quot; &quot;C:\Inetpub\TDI Web Page\Databases\TDIDB.mdb&quot; /x:extensions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top