Wednesday, June 8, 2005

VBScript to delete all files older than 2 months

const fldname = "c:\test"
set fso = createobject("scripting.filesystemobject")
set fldr = fso.getfolder(fldname)
set dttoday = date
set dt2monthsago = dateadd("m", -2, dttoday)

recurse fldr

sub recurse( byref fldr)
dim subfolders,files,folder,file
set subfolders = fldr.subfolders
set files = fldr.files
wscript.echo fldr.path

for each file in files
if file.datelastmodified < dt2monthsago then
wscript.echo "Deleting " & file.name & " last modified: " & file.datelastmodified
on error resume next
file.delete
end if

next
for each folder in subfolders
recurse folder
next
set subfolders = nothing
set files = nothing
end sub

Sunday, June 5, 2005

Getting PHP to work on IIS6 on Win2K3

Copy c:\php\php.ini-distrib to c:\windows\php.ini
In IIS, under 'Home Directory', click on the 'Configuration', 'Application Mappings' tab.
Click 'Add' and enter C:\php\php5isapi.dll for .php extensionGo back to IIS.
Add and allow the PHP ISAPI Extension to IIS Web Service Extensions: C:\PHP\php5isapi.dll Open IIS Manager
Click on "Web Service Extensions"
Add a new Web service extension...Enter "PHP ISAPI Extension" as the "Extension name" Click the "Add..." button and browse to the php5isapi.dll file in your PHP install directory Check the "Set extension status to Allowed" checkbox and click "OK"

Wednesday, June 1, 2005

Getting the virtual URL of a SharePoint web app script

Request.Url doesn't give you what it says on the browser Url box. You need to use the following:

string scriptUrl = Request.ServerVariables["HTTP_VTI_SCRIPT_NAME"];
 
Jeffrey Ting Jeffrey Ting on Facebook Jeffrey Ting on Spock Jeffrey Ting on Plaxo Jeffrey Ting on Spoke Jeffrey Ting on LinkedIn