Hello Gurus....I am new to ASP and VBScript and struck with the below problem....please help me in solving.
I have ASP Script on a remote server, being invoked from a JSP (Invocation and response every thing works fine).
This ASP verifies whether a file exists on the local hard disk...if not create a file (running.txt) and run a shell script other wise...just return a message.
The shell script runs a batch file which creats a file (current_datetime.txt) and at the end deletes the running.txt and current_datetime.txt.
My problem is, the batch file could not delete the File1 (running.txt)...not sure of the reason. Below is the code what I am trying to execute....
Thanks for your time.
ASP: <%@ Language = "VBScript" %>
<%
Response.Expires = 0
Response.AddHeader "Pragma","No-Cache"
Dim objFSO, sFile, objFile, strRef, strMesg
Set objFSO = CreateObject("Scripting.FileSystemObject")
sFile = "C:\temp\running.txt"
If objFSO.FileExists(sFile) Then
' CURRENTLY RUNNING SO PROVIDE FEEDBACK
strMesg = "Sorry, a process is currently running, please try later"
Else
' CURRENTLY NOT RUNNING, SO WE CAN RUN
Set objFile = objFSO.CreateTextFile(sFile)
strRef = Request.ServerVariables("HTTP_REFERER")
set wshell = server.createobject("wscript.shell")
wshell.run "C:\projects\Test\test\ContentExtract.bat"
set wshell = nothing
strMesg = "OK, your request is being processed"
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
End If
'Set objFSO = Nothing
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<title>Test</title>
</head>
<body>
<h1>Test Content Extract</h1>
<h1>From <%=strRef%> <%=Request.ServerVariables("REMOTE_HOST") %></h1>
<h1><%=strMesg%></h1>
</body>
</html>
<%
'Set strRef = Nothing
'Set strMesg = Nothing
%>
Batch File: date /T > c:\temp\current_datetime.txt
echo " "
time /T >> c:\temp\current_datetime.txt
ping
www.yahoo.com -n 20
del c:\temp\current_datetime.txt
del c:\temp\running.txt