% @ LANGUAGE = VBScript %>
<% Option Explicit %>
<% Response.Buffer=true %>
AspAppRestart Demo
<%
Dim objApp, objFile, strPath, vntAppRoot, intPos
If Request.form("hFlag1") =1 Then
Application("test")=Request.form("AppVar")
End If
If Request.form("hFlag2") =1 Then
vntPath=Request.ServerVariables("PATH_INFO")
Set objFile=GetObject("IIS://Localhost/W3svc/1/Root" & vPath)
strAppRoot=oFile.AppRoot
Set objFile=Nothing
Set objApp= GetObject("IIS://Localhost/" & mid(strAppRoot,5))
'call aspAppRestart and refresh asp.
'all application variables are gone
objApp.aspAppRestart
Response.Clear
Response.Redirect("aspAppRestart.asp")
End If
%>
AspAppRestart Demo
For this sample to work properly, you need to do following
1) Your NT account needs to have IIS admin permission
2) start MMC version internet service manager
3) locate aspAppRestart.asp file from the manager
4) clear anonymous authentication for this file (if It is cleared, set it on and the off.
The last step will also add the file info to metabase, which is needed in this asp file)
Application("test") = <% =Application("test") %>