********************************************************************** Tip of the Day! by Sandra Gopikrishna In ASP FileSystemObject(FSO) can be employed to backup important system files like autoexec.bat. The following short snippet elucidates the method of backing up autoexec.bat by employing FileSystemObject (FSO) <% set fso = server.createobject("scripting.FileSystemObject") 'create a backup of the autoexec.bat in the specified directory 'overwrite any previously existing file in the backup directory fso.copyfile "c:\autoexec.bat" , "c:\backup\autoexec.old", true set fso = nothing %> ********************************************************************** Tip of the Day! by Srinivasa Sivakumar Function ShowSharedResource(vComputerName) Dim objLocator, objService, objWEBMCol, objWEBM Set objLocator = CreateObject("WbemScripting.SWbemLocator") 'Establish a connection to WMI If isEmpty(vComputerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If 'Get the Webm Service object Set objWEBMCol = objService.InstancesOf("Win32_Share") Response.write "

Shared Resource:


" 'Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing Set objWEBM = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. ********************************************************************** Tip of the Day! by Sandra Gopikrishna In ASP.NET we can determine the type of browser that the client is employing using Request.Browser object. Request.Browser object in ASP.NET is provided with a method by name 'Browser' that returns the name of the browser employed by the client. The following piece of code demonstrates the process of browser sniffing in ASP.NET using request.browser onbject. browsersniff.aspx ----------------- ********************************************************************** Tip of the Day! by Ian Vink After doing an XSLT transformation on an XML document, to view the resulting XML, simply "copy all" (CTRL+A, CTRL+C) the page as it views in IE, then switch to Frontpage and press paste (CTRL+V). In the HTML view then will be the resulting HTML generated code. ********************************************************************** Tip of the Day! by João Vilaça A simple way to prevent a user from downloading your .mdb file is to keep it in a folder whose name starts with an underscore. That way, if the user tryes to get your file using http://www.yourserver.com/_mydbfile/whatever.mdb the browser will be unable to download it (at least IE won't). ********************************************************************** Tip of the Day! by Sandra Gopikrishna The Software that is being used by the webserver can be retrieved by employing the following server variable: <% response.write "The webserver uses the following Software" & _ request.servervariables("SERVER_SOFTWARE") %> ********************************************************************** Tip of the Day! by Ian Vink SQL = "SELECT Membership " SQL = SQL & "FROM tblWorldReligion " SQL = SQL & "WHERE Religion ='Bahai' " SQL = SQL & "AND GenderEquality=1 " set RS = CN.Execute (SQL) ********************************************************************** Tip of the Day! by Sandra Gopikrishna In ASP page it is possible to find out whether a particular component is installed or not by employing the following intelligent piece of code . The following ASP script employs number property of err object provided with VBScript to achieve the above specified task. <% on error resume next 'create an instance of the object set obj = server.createobject("testdll.myfunction") 'check whether the object is instantiated succesfully or not if err.number <> 0 then Response.write err.description else if err.number = 0 then Response.write "Component Instantiated Successfully" end if %> ********************************************************************** Tip of the Day! by João Vilaça Most ASP developers create connections where they are not useful. For instance: dim rs, con set rs=server.createObject ("ADODB.recordset") set con=server.createObject ("ADODB.Connection") con.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&server.mappath ("filename.mdb")&";" rs.open "SELECT * FROM table", con ... rs.close set rs = Nothing con.close set con = Nothing may become: dim rs set rs=server.createObject ("ADODB.recordset") rs.open "SELECT * FROM table", "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&server.mappath ("filename.mdb")&";" ... rs.close set rs = Nothing ********************************************************************** Tip of the Day! by Srinivasa Sivakumar Function ShowDCOMAppSettings(vComputerName) Dim objLocator, objService, objWEBMCol, objWEBM Set objLocator = CreateObject("WbemScripting.SWbemLocator") 'Establish a connection to WMI If isEmpty(vServerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If 'Get the Webm Service object Set objWEBMCol = objService.InstancesOf("Win32_DCOMApplicationSetting") Response.write "

DCOM Application Settings:


" 'Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing Set objWEBM = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. ********************************************************************** Tip of the Day! by Sandra Gopikrishna How to list all Logical Memory Configuration information from ASP? Function ShowLogicalMemoryConfiguration(vComputerName) Dim objLocator, objService, objWEBMCol, objWEBM Set objLocator = CreateObject("WbemScripting.SWbemLocator") ‘Establish a connection to WMI If isEmpty(vComputerName) = True then Set objService = objLocator.ConnectServer Else Set objService = objLocator.ConnectServer(vComputerName) End If ‘Get the Webm Service object Set objWEBMCol = objService.InstancesOf("Win32_LogicalMemoryConfiguration") Response.write "

Logical Memory Configuration:


" ‘Clean up Set objLocator = Nothing Set objService = Nothing Set objWEBMCol = Nothing Set objWEBM = Nothing End Function Note: Pass the computer name as the parameter. An empty string will work when you are accessing the local computer. ********************************************************************** Tip of the Day! by Sandra Gopikrishna In ASP.NET a text file can be deleted by employing the Delete method of File class present in "System.IO" Name space. The Following snippet demonstrates a method of deleting an already existing text file in ASP.NET. deletetext.aspx --------------- <%@ Import Namespace="System.IO" %> <% 'Pass The File name to be deleted as a parameter to Delete method of File class File.Delete("c:\myfile.txt" ) response.write("The File is deleted successfully !!!" ) %> ********************************************************************** Tip of the Day! by Srinivasa Sivakumar The GetGeneration method of the System.GC class can tell us where (Which generation) the current object resides. <% @Import Namespace="System " %> ********************************************************************** Tip of the Day! by Sandra Gopikrishna The following piece of code shows a method of retrieving the webserver port number to which the client request is being sent. <% response.write "Request was sent to the following port of the webserver" & _ request.servervariables("SERVER_PORT") %> ********************************************************************** Tip of the Day! by Ian Vink If you've ever wanted to know how many other webs are hosted along with yours on your ISP server, run this little script. I found there were 483 other webs on the server I was on. <% set fso = server.CreateObject("scripting.filesystemobject") 'Get your folder YourMainFolder = Request.ServerVariables("APPL_PHYSICAL_PATH") 'Then get the sub folder under you that contains all the sub webs SystemMainFolder = fso.GetFolder(YourMainFolder).ParentFolder 'Print the folder names of all the webs on the server you are on Response.Write "
    " for each folder in fso.GetFolder(SystemMainFolder).SubFolders Response.Write "
  1. " & folder.path & "
    " next Response.Write "
" set fso = nothing %> **********************************************************************