Java: Example - Bouncing Ball
This program does a simple animation. Animation is done by creating a timer which calls an ActionListener at fixed intervals (eg, every 35 milliseconds). The listener tells the ball to move it's coordinates a little, then it repaints the panel. repaint() indirectly calls our paintComponent() method, which then draws the ball with the updated coordinates.
BBDemo.java - The main program and window creation
// File: animation/bb/BBDemo.java
// Description: Illustrates animation with a ball bouncing in a box
// Possible extensions: faster/slower button,
// Author: Fred Swartz
// Date: February 2005 ...
import javax.swing.*;
/////////////////////////////////////////////////////////////// BBDemo
public class BBDemo extends JApplet {
//============================================== applet constructor
public BBDemo() {
add(new BBPanel());
}
//============================================================ main
public static void main(String[] args) {
JFrame win = new JFrame("Bouncing Ball Demo");
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setContentPane(new BBPanel());
win.pack();
win.setVisible(true);
}
}//endclass BBDemo
BBPanel.java - The JPanel which organizes the GUI
// File: animation/bb/BBPanel.java
// Description: Panel to layout buttons and graphics area.
// Author: Fred Swartz
// Date: February 2005
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/////////////////////////////////////////////////////////////////// BBPanel
class BBPanel extends JPanel {
BallInBox m_bb; // The bouncing ball panel
//========================================================== constructor
/** Creates a panel with the controls and bouncing ball display. */
BBPanel() {
//... Create components
m_bb = new BallInBox();
JButton startButton = new JButton("Start");
JButton stopButton = new JButton("Stop");
//... Add Listeners
startButton.addActionListener(new StartAction());
stopButton.addActionListener(new StopAction());
//... Layout inner panel with two buttons horizontally
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout());
buttonPanel.add(startButton);
buttonPanel.add(stopButton);
//... Layout outer panel with button panel above bouncing ball
this.setLayout(new BorderLayout());
this.add(buttonPanel, BorderLayout.NORTH);
this.add(m_bb , BorderLayout.CENTER);
}//end constructor
////////////////////////////////////// inner listener class StartAction
class StartAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
m_bb.setAnimation(true);
}
}
//////////////////////////////////////// inner listener class StopAction
class StopAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
m_bb.setAnimation(false);
}
}
}//endclass BBPanel
BallInBox.java - The graphics panel that does the animation.
// File: animation/bb/BouncingBall.java
// Description: This Graphics panel simulates a ball bouncing in a box.
// Animation is done by changing instance variables
// in the timer's actionListener, then calling repaint().
// * Flicker can be reduced by drawing into a BufferedImage,
// and/or using a clip region.
// * The edge of the oval could be antialiased (using Graphics2).
// Author: Fred Swartz
// Date: February 2005
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/////////////////////////////////////////////////////////////// BouncingBall
public class BallInBox extends JPanel {
//============================================== fields
//... Instance variables representing the ball.
private Ball m_ball = new Ball(0, 0, 2, 3);
//... Instance variables for the animiation
private int m_interval = 35; // Milliseconds between updates.
private Timer m_timer; // Timer fires to anmimate one step.
//========================================================== constructor
/** Set panel size and creates timer. */
public BallInBox() {
setPreferredSize(new Dimension(200, 80));
setBorder(BorderFactory.createLineBorder(Color.BLACK));
m_timer = new Timer(m_interval, new TimerAction());
}
//========================================================= setAnimation
/** Turn animation on or off.
*@param turnOnOff Specifies state of animation.
*/
public void setAnimation(boolean turnOnOff) {
if (turnOnOff) {
m_timer.start(); // start animation by starting the timer.
} else {
m_timer.stop(); // stop timer
}
}
//======================================================= paintComponent
public void paintComponent(Graphics g) {
super.paintComponent(g); // Paint background, border
m_ball.draw(g); // Draw the ball.
}
//////////////////////////////////// inner listener class ActionListener
class TimerAction implements ActionListener {
//================================================== actionPerformed
/** ActionListener of the timer. Each time this is called,
* the ball's position is updated, creating the appearance of
* movement.
*@param e This ActionEvent parameter is unused.
*/
public void actionPerformed(ActionEvent e) {
m_ball.setBounds(getWidth(), getHeight());
m_ball.move(); // Move the ball.
repaint(); // Repaint indirectly calls paintComponent.
}
}
}//endclass
Ball.java - The logic/model of the ball.
This class holds the information about the ball, its diameter, position, and velocity. Other attributes are possible (eg, color). This ball knows nothing about animation, only about its current state, how to update its coordinates, and how to draw itself.
// File: animation/bb/BallModel.java
// Description: The logic / model of a ball.
// Author: Fred Swartz
// Date: February 2005
import java.awt.*;
///////////////////////////////////////////////////////////////// BallModel
public class Ball {
//... Constants
final static int DIAMETER = 21;
//... Instance variables
private int m_x; // x and y coordinates upper left
private int m_y;
private int m_velocityX; // Pixels to move each time move() is called.
private int m_velocityY;
private int m_rightBound; // Maximum permissible x, y values.
private int m_bottomBound;
//======================================================== constructor
public Ball(int x, int y, int velocityX, int velocityY) {
m_x = x;
m_y = y;
m_velocityX = velocityX;
m_velocityY = velocityY;
}
//======================================================== setBounds
public void setBounds(int width, int height) {
m_rightBound = width - DIAMETER;
m_bottomBound = height - DIAMETER;
}
//============================================================== move
public void move() {
//... Move the ball at the give velocity.
m_x += m_velocityX;
m_y += m_velocityY;
//... Bounce the ball off the walls if necessary.
if (m_x < 0) { // If at or beyond left side
m_x = 0; // Place against edge and
m_velocityX = -m_velocityX; // reverse direction.
} else if (m_x > m_rightBound) { // If at or beyond right side
m_x = m_rightBound; // Place against right edge.
m_velocityX = -m_velocityX; // Reverse direction.
}
if (m_y < 0) { // if we're at top
m_y = 0;
m_velocityY = -m_velocityY;
} else if (m_y > m_bottomBound) { // if we're at bottom
m_y = m_bottomBound;
m_velocityY = -m_velocityY;
}
}
//============================================================== draw
public void draw(Graphics g) {
g.fillOval(m_x, m_y, DIAMETER, DIAMETER);
}
//============================================= getDiameter, getX, getY
public int getDiameter() { return DIAMETER;}
public int getX() { return m_x;}
public int getY() { return m_y;}
//======================================================== setPosition
public void setPosition(int x, int y) {
m_x = x;
m_y = y;
}
}
Copyleft 2005 Fred Swartz MIT License
Friday, January 23, 2009
Friday, January 16, 2009
Unknown XP Secrets
Hidden Programs In Windows Xp
1) Private Character Editor
This program is for designing icons and Characters(Alphapet)
cl!ck :start
Then :run
type :EUDCEDIT
.................................................. .................................................. .............................................
2) iExpress
This Program is for converting your files to EXECUTABLE files
cl!ck : start
Then : run
type : iexpress
.................................................. .................................................. .............................................
3)Disk Cleanup
This program used for cleaning harddisk to offer space
cl!ck : start
Then : run
type : cleanmgr
.................................................. .................................................. .............................................
4)Dr Watson
This program Is for repairing problems in Windows
cl!ck : start
Then : run
type : drwtsn32
.................................................. .................................................. .............................................
5)Windows Media Player 5.1
Opens the old media player
cl!ck : start
Then : run
type : mplay32
.................................................. .................................................. .............................................
Well Some More XP Secrets
Windows XP - Secrets
Deleting System Softwares:
XP hides some system software you might want to remove, such as Windows Messenger, but you can tickle it and make it disgorge everything. Using Notepad or Edit, edit the text file /windows/inf/ sysoc.inf, search for the word 'hide' and remove it. You can then go to the Add or Remove Programs in the Control Panel, select Add/Remove Windows Components and there will be your prey, exposed and vulnerable.
================================================== =================
Creating Shutdown Icon or One cl!ck Shutdown:
Navigate to your desktop. On the desktop, right-cl!ck and go to New, then to Shortcut (in other words, create a new shortcut). You should now see a pop-up window instructing you to enter a command line path.
Use this path in "Type Location of the Item"
SHUTDOWN -s -t 01
If the C: drive is not your local hard drive, then replace "C" with the correct letter of the hard drive. cl!ck the "Next" button. Name the shortcut and cl!ck the "Finish" button. Now whenever you want to shut down, just cl!ck on this shortcut and you're done.
================================================== =================
Increasing Band-Width By 20%:
Microsoft reserves 20% of your available bandwidth for their own purposes like Windows Updates and interrogating your PC etc
To get it back:
cl!ck Start then Run and type " gpedit.msc" without quotes.This opens the group policy editor. Then go to:
Local Computer Policy then Computer Configuration then Administrative Templates then Network then QOS Packet Scheduler and then to Limit Reservable Bandwidth.
Double cl!ck on Limit Reservable bandwidth. It will say it is not configured, but the truth is under the 'Explain' tab i.e."By default, the Packet Scheduler limits the system to 20 percent of the bandwidth of a connection, but you can use this setting to override the default."
So the trick is to ENABLE reservable bandwidth, then set it to ZERO. This will allow the system to reserve nothing, rather than the default 20%.It works on Win 2000 as well.
================================================== =================
Renaming The Recycle Bin icon:
To change the name of the Recycle Bin desktop icon, cl!ck Start then goto Run, write Regedit and press Enter. It opens Registry Editor. Now in Registry Editor go to:
HKEY_CLASSES_ ROOT/CLSID/ {645FF040- 5081-101B- 9F08-00AA002F954 E}
and change the name "Recycle Bin" to whatever you want (don't type any quotes).
Managing Tasks:
You can at last get rid of tasks on the computer from the command line by using 'taskkill /pid' and the task number, or just 'tskill' and the process number. Find that out by typing 'tasklist', which will also tell you a lot about what's going on in your system.
================================================== =================
Removing Shared Documents folder From My Computer window:
Open registry editor by going to Start then Run and entering regedit. Once in registry, navigate to key
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ My Computer \ NameSpace \ DelegateFolders
You must see a sub-key named {59031a47-3f72- 44a7-89c5- 5595fe6b30ee} . If you delete this key, you have effectively removed the my shared documents folder.
================================================== =================
Improving the Slow Boot up time:
There are a variety of reasons why your windows XP system would boot slowly. Most of the times it this has to do with the startup applications. If you would like to speed up the bootup sequence, consider removing some of the startup applications that you do not need. Easiest way to remove startup apps is through System Configuration Utility. Go to Start then Run and enter MSCONFIG and go to the Startup tab. Deselect/UnCheck application( s) that you do not want to startup at boot time.
================================================== =================
Customize Logon prompt with your Own Words:
Open Registry by going to Start then Run, entering regedit and Navigate to [HKEY_LOCAL_ MACHINE\SOFTWARE \Microsoft\ Windows NT\CurrentVersion\ Winlogon] . In right pane, look for key by the name "LogonPrompt" . Set its value to whatever text you want to see displayed at login screen.
IP address of your connection:
Go to Start then Run. Enter 'cmd' and then enter 'ipconfig' .Add the '/all' switch for more info .
================================================== =================
Making Folders Private:
Open My Computer Double-cl!ck the drive where Windows is installed (usually drive (C, unless you have more than one drive on your computer). If the contents of the drive are hidden, under System Tasks, cl!ck Show the contents of this drive.
Double-cl!ck the Documents and Settings folder. Double-cl!ck your user folder. Right-cl!ck any folder in your user profile, and then cl!ck Properties. On the Sharing tab, select the Make this folder private so that only I have access to it check box.
================================================== =================
To change Drive Letters:
Go to Start > Control Panel > Administrative Tools > Computer Management, Disk Management, then right-cl!ck the partition whose name you want to change (cl!ck in the white area just below the word "Volume") and select "change drive letter and paths."
From here you can add, remove or change drive letters and paths to the partition.
================================================== =================
Removing the Shortcut arrow from Desktop Icons:
Goto Start then Run and Enter regedit. Navigate to HKEY_CLASSES_ ROOTlnkfile. Delete the IsShortcut registry value. You may need to restart Windows XP.
Get Drivers for your Devices:
Visit Windows Update (XP Only)
Look at the left hand pane and under Other Options cl!ck Personalize Windows Update.
Now in the right hand pane check the box - Display the link to the Windows Update Catalog under See Also
Below Choose which categories and updates to display on Windows Update - make sure you check all the boxes you want shown.
cl!ck Save Settings
Now look in the left hand pane under See Also cl!ck Windows Update Catalog and choose what you're looking for. Choose either MS updates or drivers for hardware devices.
Start the Wizard and off you go.
Customize Internet Explorer's Title Bar:
Open Registry by going to Start then Run and Enter regedit. Navigate to HKEY_CURRENT_ USER\Software\ Microsoft\ Internet. Explorer\Main. In right hand panel look for string "Window Title" and change its value to whatever custom text you want to see.
Disabling the use of Win Key:
If your are a gaming freak then you must be sick of the Win key in your keyboard. To disable use of Win key, open registry by going to Start then Run and entering regedit. Navigate to [HKEY_LOCAL_ MACHINE\SYSTEM\ CurrentControlSe t\Control\ Keyboard Layout] . In this look for value of "Scancode Map". Its binary data so be extra careful:
Set its value to "00 00 00 00 00 00 00 00 03 00 00 00 00 00 5B E0 00 00 5C E0 00 00 00 00" to disable the win key.
Restarting Windows without Restarting the Computer:
This one is again is. When you cl!ck on the SHUTDOWN button, make sure to simultaneous press SHIFT Button. If you hold the Shift key down while *** on SHUTDOWN button, you computer would restart without restarting the Computer. This is equivalent to term "HOT REBOOT".
Stopping XP from displaying unread messages count on Welcome Screen:
To stop XP from displaying count of unread messages, Open registry and navigate to [HKEY_CURRENT_ USER\Software\ Microsoft\ Windows\CurrentV ersion\UnreadMai l] and look for the data key "MessageExpiryDays" . If you do not see this key, create one DWORD key by the name "MessageExpiryDays" . Setting its value to 0 would stop Windows XP from displaying the count of unread messages.
Modify Color Selection of Default Theme:
Open registry by going to Start then Run. Entering regedit, navigate to [HKEY_USERS\ .DEFAULT\ Software\ Microsoft\ Windows\CurrentV ersion\ThemeMana ger] and locate the key "ColorName".
Right cl!ck on it and select modify its value from "NormalColor" to "Metallic"
cl!ck Ok, and exit regedit and restart your computer.
Removing the Recycle Bin from the Desktop:
If you don't use the Recycle Bin to store deleted files , you can get rid of its desktop icon all together. Run Regedit and go to:
HKEY_LOCAL_MACHINE/ SOFTWARE/ Microsoft/ Windows/CurrentV ersion/explorer/ Desktop/NameSpace
Windows Xp Registry Tips & Tweaks
Modifying the Disk Check Autochk.exe Time-out (Scandisk Delay) Value from 10 seconds to 3 Seconds
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Session Manager]
"AutoChkTimeOut"=dword:00000003
Disable Automatic Restart in the event of a System Crash / BSOD
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\CrashControl]
"AutoReboot"=dword:00000000
Disable The Windows XP Desktop Cleanup Wizard (Unused Desktop Shortcuts)
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\Desktop\CleanupWiz]
"NoRun"=dword:00000001
Speed up Network Browsing by Removing Network Scheduled Tasks
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer\RemoteComputer\NameSpace\{D627 7990-4C6A-11CF-8D87-00AA0060F5BF}]
Disables Windows Take A Tour Bubble Popup
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\Applets\Tour]
"RunCount"=dword:00000000
Disable Remote Registry Service (Remote users to modify registry settings on your computer. Now registry can be modified only by users on your computer)
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\RemoteRegistry]
"Start"=dword:00000004
Removes the Recent Documents from the Start menu. The system saves a shortcut to each of the non-program files the user opened most recently, and it displays the shortcuts on the Recent Documents.
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Policies\Explorer]
"NoRecentDocsMenu"=dword:00000001
Classic Search, Full Path In Title Bar And Address Bar. This allows you to disable the new Search Assistant Dog and use the traditional search interface in Windows Explorer
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\CabinetState]
"FullPath"=dword:00000000
"FullPathAddress"=dword:00000001
"Use Search Asst"="no"
"Settings"=hex:0c,00,02,00,1b,01,e7,77,60,00,0 0,00
Have you ever wanted to Rename Recycle Bin ? This Tweak Allows Renaming of Recycle Bin
[HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder]
"Attributes"=hex:50,01,00,20
"CallForAttributes"=dword:00000000
Are you getting 'Low Disk Space Notification' ? This Disables Low Diskspace Warnings
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Policies\Explorer]
"NoLowDiskSpaceChecks"=dword:00000001
Do you want to Speedup the Windows XP Start Menu?
[HKEY_CURRENT_USER\Control Panel\Desktop]
"MenuShowDelay"="2"
Maximize Your Internet Explorer's Simultaneous Downloads From 2 to 10 Connections
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Internet Settings]
"MaxConnectionsPer1_0Server"=dword:0000000a
"MaxConnectionsPerServer"=dword:0000000a
Remove the Queue-it-up, Burn to CD right cl!ck options on Windows Media Player files.
[-HKEY_CLASSES_ROOT\CLSID\{CE3FB1D1-02AE-4a5f-A6E9-D9F1B4073E6C}]
[-HKEY_CLASSES_ROOT\CLSID\{F1B9284F-E9DC-4e68-9D7E-42362A59F0FD}]
[-HKEY_CLASSES_ROOT\CLSID\{8DD448E6-C188-4aed-AF92-44956194EB1F}]
Removes Sign up with Passport Wizard when trying to sign in MSN Messenger First time
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Internet Settings\Passport]
"RegistrationCompleted"=dword:00000001
Disables Preview (Thumbnails) of Movie File Formats (Allowing You To Move/Rename/Delete without Errors)
[-HKEY_CLASSES_ROOT\.avi\ShellEx]
[-HKEY_CLASSES_ROOT\.mpg\ShellEx]
[-HKEY_CLASSES_ROOT\.mpe\ShellEx]
[-HKEY_CLASSES_ROOT\.mpeg\ShellEx]
[-HKEY_CLASSES_ROOT\.mov\ShellEx]
Open Explorer From My Computer or Any Folder (Power users love this)
[HKEY_CLASSES_ROOT\Folder\shell]
@="explore"
Remove 'Shortcut To ...' Prefix when you create new Shortcut
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer]
"link"=hex:00,00,00,00
This **** 'Command Prompt here' on Right cl!ck Menu (When you right cl!ck on a Drive/Folder)
[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt Here]
@="Command &Prompt Here"
[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt Here\command]
@="cmd.exe /k cd %1 "
[HKEY_CLASSES_ROOT\Drive\shell\Command Prompt Here]
@="Command &Prompt Here"
[HKEY_CLASSES_ROOT\Drive\shell\Command Prompt Here\command]
@="cmd.exe /k cd %1 "
Remove Shared Documents folders from My Computer System Folder
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer\MyComputer\NameSpace\DelegateF olders\{59031a47-3f72-44a7-89c5-5595fe6b30ee}]
Disable the Unread Mail Message on the Welcome Screen
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\UnreadMail\]
"MessageExpiryDays"=dword:00000000
Disable Compress Old Files (This is useful when Disk Cleanup Tool Stops Responding While Compressing Old Files)
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer\VolumeCaches\Compress old files]
Windows Explorer Crashes When Opening Folder Containing avi/video files
[-HKEY_CLASSES_ROOT\CLSID\{87D62D94-71B3-4b9a-9489-5FE6850DC73E}]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.avi\shel lex\PropertyHandler]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{87D62D9 4-71B3-4b9a-9489-5FE6850DC73E}\InProcServer32]
================================================== ==============
Send Out Executable Files Via Gmail
As a security measure to prevent the intrusion of potential viruses, Gmail strictly disallows users to send and receive executable files (files with the extension ".exe", ".dll", ".ocx" or ".bat") in its policy. If you try to send these files, Gmail will send you an error message: "This is an executable file. For security reasons, Gmail does not allow you to send this type of file." You might try to zip or compress the files into other formats such as ".zip", ".tar", ".tgz", ".taz", ".z" or ".gz". However, your Gmail account will bounce back your message. How to send executable files with your Gmail account if you really need to do so?
Of course the easiest way is to use other email services such as Yahoo to send your important executable files. However, if you are still set on using Gmail to send your executable files, there are a few ways you can try: -
1. You can rename your executable files from the "exe" extension to other formats such as "doc", "jpeg", etc. For instance, your file name is happy.exe; just rename your file to happy.doc and send it over to the receivers. Once the receivers have received the files, they just need to change the extension back to the original file extension.
2. The other way you can try is upload your executable files to some free file hosting service such as DivShare or Rapidshare. Copy down the link and send it to the receivers. It's pretty straightforward.
3. The last option you can try is to compress your executable file by using Winrar. Gmails doesn't scan files in the RAR format. You can send the file out without a problem. However, you must make sure your receivers can open the RAR files
1) Private Character Editor
This program is for designing icons and Characters(Alphapet)
cl!ck :start
Then :run
type :EUDCEDIT
.................................................. .................................................. .............................................
2) iExpress
This Program is for converting your files to EXECUTABLE files
cl!ck : start
Then : run
type : iexpress
.................................................. .................................................. .............................................
3)Disk Cleanup
This program used for cleaning harddisk to offer space
cl!ck : start
Then : run
type : cleanmgr
.................................................. .................................................. .............................................
4)Dr Watson
This program Is for repairing problems in Windows
cl!ck : start
Then : run
type : drwtsn32
.................................................. .................................................. .............................................
5)Windows Media Player 5.1
Opens the old media player
cl!ck : start
Then : run
type : mplay32
.................................................. .................................................. .............................................
Well Some More XP Secrets
Windows XP - Secrets
Deleting System Softwares:
XP hides some system software you might want to remove, such as Windows Messenger, but you can tickle it and make it disgorge everything. Using Notepad or Edit, edit the text file /windows/inf/ sysoc.inf, search for the word 'hide' and remove it. You can then go to the Add or Remove Programs in the Control Panel, select Add/Remove Windows Components and there will be your prey, exposed and vulnerable.
================================================== =================
Creating Shutdown Icon or One cl!ck Shutdown:
Navigate to your desktop. On the desktop, right-cl!ck and go to New, then to Shortcut (in other words, create a new shortcut). You should now see a pop-up window instructing you to enter a command line path.
Use this path in "Type Location of the Item"
SHUTDOWN -s -t 01
If the C: drive is not your local hard drive, then replace "C" with the correct letter of the hard drive. cl!ck the "Next" button. Name the shortcut and cl!ck the "Finish" button. Now whenever you want to shut down, just cl!ck on this shortcut and you're done.
================================================== =================
Increasing Band-Width By 20%:
Microsoft reserves 20% of your available bandwidth for their own purposes like Windows Updates and interrogating your PC etc
To get it back:
cl!ck Start then Run and type " gpedit.msc" without quotes.This opens the group policy editor. Then go to:
Local Computer Policy then Computer Configuration then Administrative Templates then Network then QOS Packet Scheduler and then to Limit Reservable Bandwidth.
Double cl!ck on Limit Reservable bandwidth. It will say it is not configured, but the truth is under the 'Explain' tab i.e."By default, the Packet Scheduler limits the system to 20 percent of the bandwidth of a connection, but you can use this setting to override the default."
So the trick is to ENABLE reservable bandwidth, then set it to ZERO. This will allow the system to reserve nothing, rather than the default 20%.It works on Win 2000 as well.
================================================== =================
Renaming The Recycle Bin icon:
To change the name of the Recycle Bin desktop icon, cl!ck Start then goto Run, write Regedit and press Enter. It opens Registry Editor. Now in Registry Editor go to:
HKEY_CLASSES_ ROOT/CLSID/ {645FF040- 5081-101B- 9F08-00AA002F954 E}
and change the name "Recycle Bin" to whatever you want (don't type any quotes).
Managing Tasks:
You can at last get rid of tasks on the computer from the command line by using 'taskkill /pid' and the task number, or just 'tskill' and the process number. Find that out by typing 'tasklist', which will also tell you a lot about what's going on in your system.
================================================== =================
Removing Shared Documents folder From My Computer window:
Open registry editor by going to Start then Run and entering regedit. Once in registry, navigate to key
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ My Computer \ NameSpace \ DelegateFolders
You must see a sub-key named {59031a47-3f72- 44a7-89c5- 5595fe6b30ee} . If you delete this key, you have effectively removed the my shared documents folder.
================================================== =================
Improving the Slow Boot up time:
There are a variety of reasons why your windows XP system would boot slowly. Most of the times it this has to do with the startup applications. If you would like to speed up the bootup sequence, consider removing some of the startup applications that you do not need. Easiest way to remove startup apps is through System Configuration Utility. Go to Start then Run and enter MSCONFIG and go to the Startup tab. Deselect/UnCheck application( s) that you do not want to startup at boot time.
================================================== =================
Customize Logon prompt with your Own Words:
Open Registry by going to Start then Run, entering regedit and Navigate to [HKEY_LOCAL_ MACHINE\SOFTWARE \Microsoft\ Windows NT\CurrentVersion\ Winlogon] . In right pane, look for key by the name "LogonPrompt" . Set its value to whatever text you want to see displayed at login screen.
IP address of your connection:
Go to Start then Run. Enter 'cmd' and then enter 'ipconfig' .Add the '/all' switch for more info .
================================================== =================
Making Folders Private:
Open My Computer Double-cl!ck the drive where Windows is installed (usually drive (C, unless you have more than one drive on your computer). If the contents of the drive are hidden, under System Tasks, cl!ck Show the contents of this drive.
Double-cl!ck the Documents and Settings folder. Double-cl!ck your user folder. Right-cl!ck any folder in your user profile, and then cl!ck Properties. On the Sharing tab, select the Make this folder private so that only I have access to it check box.
================================================== =================
To change Drive Letters:
Go to Start > Control Panel > Administrative Tools > Computer Management, Disk Management, then right-cl!ck the partition whose name you want to change (cl!ck in the white area just below the word "Volume") and select "change drive letter and paths."
From here you can add, remove or change drive letters and paths to the partition.
================================================== =================
Removing the Shortcut arrow from Desktop Icons:
Goto Start then Run and Enter regedit. Navigate to HKEY_CLASSES_ ROOTlnkfile. Delete the IsShortcut registry value. You may need to restart Windows XP.
Get Drivers for your Devices:
Visit Windows Update (XP Only)
Look at the left hand pane and under Other Options cl!ck Personalize Windows Update.
Now in the right hand pane check the box - Display the link to the Windows Update Catalog under See Also
Below Choose which categories and updates to display on Windows Update - make sure you check all the boxes you want shown.
cl!ck Save Settings
Now look in the left hand pane under See Also cl!ck Windows Update Catalog and choose what you're looking for. Choose either MS updates or drivers for hardware devices.
Start the Wizard and off you go.
Customize Internet Explorer's Title Bar:
Open Registry by going to Start then Run and Enter regedit. Navigate to HKEY_CURRENT_ USER\Software\ Microsoft\ Internet. Explorer\Main. In right hand panel look for string "Window Title" and change its value to whatever custom text you want to see.
Disabling the use of Win Key:
If your are a gaming freak then you must be sick of the Win key in your keyboard. To disable use of Win key, open registry by going to Start then Run and entering regedit. Navigate to [HKEY_LOCAL_ MACHINE\SYSTEM\ CurrentControlSe t\Control\ Keyboard Layout] . In this look for value of "Scancode Map". Its binary data so be extra careful:
Set its value to "00 00 00 00 00 00 00 00 03 00 00 00 00 00 5B E0 00 00 5C E0 00 00 00 00" to disable the win key.
Restarting Windows without Restarting the Computer:
This one is again is. When you cl!ck on the SHUTDOWN button, make sure to simultaneous press SHIFT Button. If you hold the Shift key down while *** on SHUTDOWN button, you computer would restart without restarting the Computer. This is equivalent to term "HOT REBOOT".
Stopping XP from displaying unread messages count on Welcome Screen:
To stop XP from displaying count of unread messages, Open registry and navigate to [HKEY_CURRENT_ USER\Software\ Microsoft\ Windows\CurrentV ersion\UnreadMai l] and look for the data key "MessageExpiryDays" . If you do not see this key, create one DWORD key by the name "MessageExpiryDays" . Setting its value to 0 would stop Windows XP from displaying the count of unread messages.
Modify Color Selection of Default Theme:
Open registry by going to Start then Run. Entering regedit, navigate to [HKEY_USERS\ .DEFAULT\ Software\ Microsoft\ Windows\CurrentV ersion\ThemeMana ger] and locate the key "ColorName".
Right cl!ck on it and select modify its value from "NormalColor" to "Metallic"
cl!ck Ok, and exit regedit and restart your computer.
Removing the Recycle Bin from the Desktop:
If you don't use the Recycle Bin to store deleted files , you can get rid of its desktop icon all together. Run Regedit and go to:
HKEY_LOCAL_MACHINE/ SOFTWARE/ Microsoft/ Windows/CurrentV ersion/explorer/ Desktop/NameSpace
Windows Xp Registry Tips & Tweaks
Modifying the Disk Check Autochk.exe Time-out (Scandisk Delay) Value from 10 seconds to 3 Seconds
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Session Manager]
"AutoChkTimeOut"=dword:00000003
Disable Automatic Restart in the event of a System Crash / BSOD
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\CrashControl]
"AutoReboot"=dword:00000000
Disable The Windows XP Desktop Cleanup Wizard (Unused Desktop Shortcuts)
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\Desktop\CleanupWiz]
"NoRun"=dword:00000001
Speed up Network Browsing by Removing Network Scheduled Tasks
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer\RemoteComputer\NameSpace\{D627 7990-4C6A-11CF-8D87-00AA0060F5BF}]
Disables Windows Take A Tour Bubble Popup
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\Applets\Tour]
"RunCount"=dword:00000000
Disable Remote Registry Service (Remote users to modify registry settings on your computer. Now registry can be modified only by users on your computer)
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\RemoteRegistry]
"Start"=dword:00000004
Removes the Recent Documents from the Start menu. The system saves a shortcut to each of the non-program files the user opened most recently, and it displays the shortcuts on the Recent Documents.
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Policies\Explorer]
"NoRecentDocsMenu"=dword:00000001
Classic Search, Full Path In Title Bar And Address Bar. This allows you to disable the new Search Assistant Dog and use the traditional search interface in Windows Explorer
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\CabinetState]
"FullPath"=dword:00000000
"FullPathAddress"=dword:00000001
"Use Search Asst"="no"
"Settings"=hex:0c,00,02,00,1b,01,e7,77,60,00,0 0,00
Have you ever wanted to Rename Recycle Bin ? This Tweak Allows Renaming of Recycle Bin
[HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder]
"Attributes"=hex:50,01,00,20
"CallForAttributes"=dword:00000000
Are you getting 'Low Disk Space Notification' ? This Disables Low Diskspace Warnings
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Policies\Explorer]
"NoLowDiskSpaceChecks"=dword:00000001
Do you want to Speedup the Windows XP Start Menu?
[HKEY_CURRENT_USER\Control Panel\Desktop]
"MenuShowDelay"="2"
Maximize Your Internet Explorer's Simultaneous Downloads From 2 to 10 Connections
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Internet Settings]
"MaxConnectionsPer1_0Server"=dword:0000000a
"MaxConnectionsPerServer"=dword:0000000a
Remove the Queue-it-up, Burn to CD right cl!ck options on Windows Media Player files.
[-HKEY_CLASSES_ROOT\CLSID\{CE3FB1D1-02AE-4a5f-A6E9-D9F1B4073E6C}]
[-HKEY_CLASSES_ROOT\CLSID\{F1B9284F-E9DC-4e68-9D7E-42362A59F0FD}]
[-HKEY_CLASSES_ROOT\CLSID\{8DD448E6-C188-4aed-AF92-44956194EB1F}]
Removes Sign up with Passport Wizard when trying to sign in MSN Messenger First time
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Internet Settings\Passport]
"RegistrationCompleted"=dword:00000001
Disables Preview (Thumbnails) of Movie File Formats (Allowing You To Move/Rename/Delete without Errors)
[-HKEY_CLASSES_ROOT\.avi\ShellEx]
[-HKEY_CLASSES_ROOT\.mpg\ShellEx]
[-HKEY_CLASSES_ROOT\.mpe\ShellEx]
[-HKEY_CLASSES_ROOT\.mpeg\ShellEx]
[-HKEY_CLASSES_ROOT\.mov\ShellEx]
Open Explorer From My Computer or Any Folder (Power users love this)
[HKEY_CLASSES_ROOT\Folder\shell]
@="explore"
Remove 'Shortcut To ...' Prefix when you create new Shortcut
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer]
"link"=hex:00,00,00,00
This **** 'Command Prompt here' on Right cl!ck Menu (When you right cl!ck on a Drive/Folder)
[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt Here]
@="Command &Prompt Here"
[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt Here\command]
@="cmd.exe /k cd %1 "
[HKEY_CLASSES_ROOT\Drive\shell\Command Prompt Here]
@="Command &Prompt Here"
[HKEY_CLASSES_ROOT\Drive\shell\Command Prompt Here\command]
@="cmd.exe /k cd %1 "
Remove Shared Documents folders from My Computer System Folder
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer\MyComputer\NameSpace\DelegateF olders\{59031a47-3f72-44a7-89c5-5595fe6b30ee}]
Disable the Unread Mail Message on the Welcome Screen
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\UnreadMail\]
"MessageExpiryDays"=dword:00000000
Disable Compress Old Files (This is useful when Disk Cleanup Tool Stops Responding While Compressing Old Files)
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer\VolumeCaches\Compress old files]
Windows Explorer Crashes When Opening Folder Containing avi/video files
[-HKEY_CLASSES_ROOT\CLSID\{87D62D94-71B3-4b9a-9489-5FE6850DC73E}]
[-HKEY_CLASSES_ROOT\SystemFileAssociations\.avi\shel lex\PropertyHandler]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{87D62D9 4-71B3-4b9a-9489-5FE6850DC73E}\InProcServer32]
================================================== ==============
Send Out Executable Files Via Gmail
As a security measure to prevent the intrusion of potential viruses, Gmail strictly disallows users to send and receive executable files (files with the extension ".exe", ".dll", ".ocx" or ".bat") in its policy. If you try to send these files, Gmail will send you an error message: "This is an executable file. For security reasons, Gmail does not allow you to send this type of file." You might try to zip or compress the files into other formats such as ".zip", ".tar", ".tgz", ".taz", ".z" or ".gz". However, your Gmail account will bounce back your message. How to send executable files with your Gmail account if you really need to do so?
Of course the easiest way is to use other email services such as Yahoo to send your important executable files. However, if you are still set on using Gmail to send your executable files, there are a few ways you can try: -
1. You can rename your executable files from the "exe" extension to other formats such as "doc", "jpeg", etc. For instance, your file name is happy.exe; just rename your file to happy.doc and send it over to the receivers. Once the receivers have received the files, they just need to change the extension back to the original file extension.
2. The other way you can try is upload your executable files to some free file hosting service such as DivShare or Rapidshare. Copy down the link and send it to the receivers. It's pretty straightforward.
3. The last option you can try is to compress your executable file by using Winrar. Gmails doesn't scan files in the RAR format. You can send the file out without a problem. However, you must make sure your receivers can open the RAR files
Friday, January 9, 2009
routing
Routing Basics
This chapter introduces the underlying concepts widely used in routing protocols. Topics summarized here include routing protocol components and algorithms. In addition, the role of routing protocols is briefly contrasted with the role of routed or network protocols. Subsequent chapters in Part VII, "Routing Protocols," address specific routing protocols in more detail, while the network protocols that use routing protocols are discussed in Part VI, "Network Protocols."
What Is Routing?
Routing is the act of moving information across an internetwork from a source to a destination. Along the way, at least one intermediate node typically is encountered. Routing is often contrasted with bridging, which might seem to accomplish precisely the same thing to the casual observer. The primary difference between the two is that bridging occurs at Layer 2 (the link layer) of the OSI reference model, whereas routing occurs at Layer 3 (the network layer). This distinction provides routing and bridging with different information to use in the process of moving information from source to destination, so the two functions accomplish their tasks in different ways.
The topic of routing has been covered in computer science literature for more than two decades, but routing achieved commercial popularity as late as the mid-1980s. The primary reason for this time lag is that networks in the 1970s were simple, homogeneous environments. Only relatively recently has large-scale internetworking become popular.
Routing Components
Routing involves two basic activities: determining optimal routing paths and transporting information groups (typically called packets) through an internetwork. In the context of the routing process, the latter of these is referred to as packet switching. Although packet switching is relatively straightforward, path determination can be very complex.
Path Determination
Routing protocols use metrics to evaluate what path will be the best for a packet to travel. A metric is a standard of measurement, such as path bandwidth, that is used by routing algorithms to determine the optimal path to a destination. To aid the process of path determination, routing algorithms initialize and maintain routing tables, which contain route information. Route information varies depending on the routing algorithm used.
Routing algorithms fill routing tables with a variety of information. Destination/next hop associations tell a router that a particular destination can be reached optimally by sending the packet to a particular router representing the "next hop" on the way to the final destination. When a router receives an incoming packet, it checks the destination address and attempts to associate this address with a next hop. Figure 5-1 depicts a sample destination/next hop routing table.
Figure 5-1 Destination/Next Hop Associations Determine the Data's Optimal Path
Routing tables also can contain other information, such as data about the desirability of a path. Routers compare metrics to determine optimal routes, and these metrics differ depending on the design of the routing algorithm used. A variety of common metrics will be introduced and described later in this chapter.
Routers communicate with one another and maintain their routing tables through the transmission of a variety of messages. The routing update message is one such message that generally consists of all or a portion of a routing table. By analyzing routing updates from all other routers, a router can build a detailed picture of network topology. A link-state advertisement, another example of a message sent between routers, informs other routers of the state of the sender's links. Link information also can be used to build a complete picture of network topology to enable routers to determine optimal routes to network destinations.
Switching
Switching algorithms is relatively simple; it is the same for most routing protocols. In most cases, a host determines that it must send a packet to another host. Having acquired a router's address by some means, the source host sends a packet addressed specifically to
a router's physical (Media Access Control [MAC]-layer) address, this time with the protocol (network layer) address of the destination host.
As it examines the packet's destination protocol address, the router determines that it either knows or does not know how to forward the packet to the next hop. If the router does not know how to forward the packet, it typically drops the packet. If the router knows how to forward the packet, however, it changes the destination physical address to that of the next hop and transmits the packet.
The next hop may be the ultimate destination host. If not, the next hop is usually another router, which executes the same switching decision process. As the packet moves through the internetwork, its physical address changes, but its protocol address remains constant, as illustrated in Figure 5-2.
The preceding discussion describes switching between a source and a destination end system. The International Organization for Standardization (ISO) has developed a hierarchical terminology that is useful in describing this process. Using this terminology, network devices without the capability to forward packets between subnetworks are called end systems (ESs), whereas network devices with these capabilities are called intermediate systems (ISs). ISs are further divided into those that can communicate within routing domains (intradomain ISs) and those that communicate both within and between routing domains (interdomain ISs). A routing domain generally is considered a portion of an internetwork under common administrative authority that is regulated by a particular set of administrative guidelines. Routing domains are also called autonomous systems. With certain protocols, routing domains can be divided into routing areas, but intradomain routing protocols are still used for switching both within and between areas.
Figure 5-2 Numerous Routers May Come into Play During the Switching Process
Routing Algorithms
Routing algorithms can be differentiated based on several key characteristics. First, the particular goals of the algorithm designer affect the operation of the resulting routing protocol. Second, various types of routing algorithms exist, and each algorithm has a different impact on network and router resources. Finally, routing algorithms use a variety of metrics that affect calculation of optimal routes. The following sections analyze these routing algorithm attributes.
Design Goals
Routing algorithms often have one or more of the following design goals:
•Optimality
•Simplicity and low overhead
•Robustness and stability
•Rapid convergence
•Flexibility
Optimality refers to the capability of the routing algorithm to select the best route, which depends on the metrics and metric weightings used to make the calculation. For example, one routing algorithm may use a number of hops and delays, but it may weigh delay more heavily in the calculation. Naturally, routing protocols must define their metric calculation algorithms strictly.
Routing algorithms also are designed to be as simple as possible. In other words, the routing algorithm must offer its functionality efficiently, with a minimum of software and utilization overhead. Efficiency is particularly important when the software implementing the routing algorithm must run on a computer with limited physical resources.
Routing algorithms must be robust, which means that they should perform correctly in
the face of unusual or unforeseen circumstances, such as hardware failures, high load conditions, and incorrect implementations. Because routers are located at network junction points, they can cause considerable problems when they fail. The best routing algorithms are often those that have withstood the test of time and that have proven stable under a variety of network conditions.
In addition, routing algorithms must converge rapidly. Convergence is the process of agreement, by all routers, on optimal routes. When a network event causes routes to either go down or become available, routers distribute routing update messages that permeate networks, stimulating recalculation of optimal routes and eventually causing all routers to agree on these routes. Routing algorithms that converge slowly can cause routing loops or network outages.
In the routing loop displayed in Figure 5-3, a packet arrives at Router 1 at time t1. Router 1 already has been updated and thus knows that the optimal route to the destination calls for Router 2 to be the next stop. Router 1 therefore forwards the packet to Router 2, but because this router has not yet been updated, it believes that the optimal next hop is Router 1. Router 2 therefore forwards the packet back to Router 1, and the packet continues to bounce back and forth between the two routers until Router 2 receives its routing update or until the packet has been switched the maximum number of times allowed.
Figure 5-3 Slow Convergence and Routing Loops Can Hinder Progress
Routing algorithms should also be flexible, which means that they should quickly and accurately adapt to a variety of network circumstances. Assume, for example, that a network segment has gone down. As many routing algorithms become aware of the problem, they will quickly select the next-best path for all routes normally using that segment. Routing algorithms can be programmed to adapt to changes in network bandwidth, router queue size, and network delay, among other variables.
Algorithm Types
Routing algorithms can be classified by type. Key differentiators include these:
•Static versus dynamic
•Single-path versus multipath
•Flat versus hierarchical
•Host-intelligent versus router-intelligent
•Intradomain versus interdomain
•Link-state versus distance vector
Static Versus Dynamic
Static routing algorithms are hardly algorithms at all, but are table mappings established by the network administrator before the beginning of routing. These mappings do not change unless the network administrator alters them. Algorithms that use static routes are simple to design and work well in environments where network traffic is relatively predictable and where network design is relatively simple.
Because static routing systems cannot react to network changes, they generally are considered unsuitable for today's large, constantly changing networks. Most of the dominant routing algorithms today are dynamic routing algorithms, which adjust to changing network circumstances by analyzing incoming routing update messages. If the message indicates that a network change has occurred, the routing software recalculates routes and sends out new routing update messages. These messages permeate the network, stimulating routers to rerun their algorithms and change their routing tables accordingly.
Dynamic routing algorithms can be supplemented with static routes where appropriate. A router of last resort (a router to which all unroutable packets are sent), for example, can be designated to act as a repository for all unroutable packets, ensuring that all messages are at least handled in some way.
Single-Path Versus Multipath
Some sophisticated routing protocols support multiple paths to the same destination. Unlike single-path algorithms, these multipath algorithms permit traffic multiplexing over multiple lines. The advantages of multipath algorithms are obvious: They can provide substantially better throughput and reliability. This is generally called load sharing.
Flat Versus Hierarchical
Some routing algorithms operate in a flat space, while others use routing hierarchies. In a flat routing system, the routers are peers of all others. In a hierarchical routing system, some routers form what amounts to a routing backbone. Packets from nonbackbone routers travel to the backbone routers, where they are sent through the backbone until they reach the general area of the destination. At this point, they travel from the last backbone router through one or more nonbackbone routers to the final destination.
Routing systems often designate logical groups of nodes, called domains, autonomous systems, or areas. In hierarchical systems, some routers in a domain can communicate with routers in other domains, while others can communicate only with routers within their domain. In very large networks, additional hierarchical levels may exist, with routers at the highest hierarchical level forming the routing backbone.
The primary advantage of hierarchical routing is that it mimics the organization of most companies and therefore supports their traffic patterns well. Most network communication occurs within small company groups (domains). Because intradomain routers need to know only about other routers within their domain, their routing algorithms can be simplified, and, depending on the routing algorithm being used, routing update traffic can be reduced accordingly.
Host-Intelligent Versus Router-Intelligent
Some routing algorithms assume that the source end node will determine the entire route. This is usually referred to as source routing. In source-routing systems, routers merely act as store-and-forward devices, mindlessly sending the packet to the next stop.
Other algorithms assume that hosts know nothing about routes. In these algorithms, routers determine the path through the internetwork based on their own calculations. In the first system, the hosts have the routing intelligence. In the latter system, routers have the routing intelligence.
Intradomain Versus Interdomain
Some routing algorithms work only within domains; others work within and between domains. The nature of these two algorithm types is different. It stands to reason, therefore, that an optimal intradomain-routing algorithm would not necessarily be an optimal interdomain-routing algorithm.
Link-State Versus Distance Vector
Link-state algorithms (also known as shortest path first algorithms) flood routing information to all nodes in the internetwork. Each router, however, sends only the portion of the routing table that describes the state of its own links. In link-state algorithms, each router builds a picture of the entire network in its routing tables. Distance vector algorithms (also known as Bellman-Ford algorithms) call for each router to send all or some portion of its routing table, but only to its neighbors. In essence, link-state algorithms send small updates everywhere, while distance vector algorithms send larger updates only to neighboring routers. Distance vector algorithms know only about their neighbors.
Because they converge more quickly, link-state algorithms are somewhat less prone to routing loops than distance vector algorithms. On the other hand, link-state algorithms require more CPU power and memory than distance vector algorithms. Link-state algorithms, therefore, can be more expensive to implement and support. Link-state protocols are generally more scalable than distance vector protocols.
Routing Metrics
Routing tables contain information used by switching software to select the best route. But how, specifically, are routing tables built? What is the specific nature of the information that they contain? How do routing algorithms determine that one route is preferable to others?
Routing algorithms have used many different metrics to determine the best route. Sophisticated routing algorithms can base route selection on multiple metrics, combining them in a single (hybrid) metric. All the following metrics have been used:
•Path length
•Reliability
•Delay
•Bandwidth
•Load
•Communication cost
Path length is the most common routing metric. Some routing protocols allow network administrators to assign arbitrary costs to each network link. In this case, path length is the sum of the costs associated with each link traversed. Other routing protocols define hop count, a metric that specifies the number of passes through internetworking products, such as routers, that a packet must take en route from a source to a destination.
Reliability, in the context of routing algorithms, refers to the dependability (usually described in terms of the bit-error rate) of each network link. Some network links might go down more often than others. After a network fails, certain network links might be repaired more easily or more quickly than other links. Any reliability factors can be taken into account in the assignment of the reliability ratings, which are arbitrary numeric values usually assigned to network links by network administrators.
Routing delay refers to the length of time required to move a packet from source to destination through the internetwork. Delay depends on many factors, including the bandwidth of intermediate network links, the port queues at each router along the way, network congestion on all intermediate network links, and the physical distance to be traveled. Because delay is a conglomeration of several important variables, it is a common and useful metric.
Bandwidth refers to the available traffic capacity of a link. All other things being equal, a 10-Mbps Ethernet link would be preferable to a 64-kbps leased line. Although bandwidth is a rating of the maximum attainable throughput on a link, routes through links with greater bandwidth do not necessarily provide better routes than routes through slower links. For example, if a faster link is busier, the actual time required to send a packet to the destination could be greater.
Load refers to the degree to which a network resource, such as a router, is busy. Load can be calculated in a variety of ways, including CPU utilization and packets processed per second. Monitoring these parameters on a continual basis can be resource-intensive itself.
Communication cost is another important metric, especially because some companies may not care about performance as much as they care about operating expenditures. Although line delay may be longer, they will send packets over their own lines rather than through the public lines that cost money for usage time.
Network Protocols
Routed protocols are transported by routing protocols across an internetwork. In general, routed protocols in this context also are referred to as network protocols. These network protocols perform a variety of functions required for communication between user applications in source and destination devices, and these functions can differ widely among protocol suites. Network protocols occur at the upper five layers of the OSI reference model: the network layer, the transport layer, the session layer, the presentation layer, and the application layer.
Confusion about the terms routed protocol and routing protocol is common. Routed protocols are protocols that are routed over an internetwork. Examples of such protocols are the Internet Protocol (IP), DECnet, AppleTalk, Novell NetWare, OSI, Banyan VINES, and Xerox Network System (XNS). Routing protocols, on the other hand, are protocols that implement routing algorithms. Put simply, routing protocols are used by intermediate systems to build tables used in determining path selection of routed protocols. Examples of these protocols include Interior Gateway Routing Protocol (IGRP), Enhanced Interior Gateway Routing Protocol (Enhanced IGRP), Open Shortest Path First (OSPF), Exterior Gateway Protocol (EGP), Border Gateway Protocol (BGP), Intermediate System-to-Intermediate System (IS-IS), and Routing Information Protocol (RIP). Routed and routing protocols are discussed in detail later in this book.
This chapter introduces the underlying concepts widely used in routing protocols. Topics summarized here include routing protocol components and algorithms. In addition, the role of routing protocols is briefly contrasted with the role of routed or network protocols. Subsequent chapters in Part VII, "Routing Protocols," address specific routing protocols in more detail, while the network protocols that use routing protocols are discussed in Part VI, "Network Protocols."
What Is Routing?
Routing is the act of moving information across an internetwork from a source to a destination. Along the way, at least one intermediate node typically is encountered. Routing is often contrasted with bridging, which might seem to accomplish precisely the same thing to the casual observer. The primary difference between the two is that bridging occurs at Layer 2 (the link layer) of the OSI reference model, whereas routing occurs at Layer 3 (the network layer). This distinction provides routing and bridging with different information to use in the process of moving information from source to destination, so the two functions accomplish their tasks in different ways.
The topic of routing has been covered in computer science literature for more than two decades, but routing achieved commercial popularity as late as the mid-1980s. The primary reason for this time lag is that networks in the 1970s were simple, homogeneous environments. Only relatively recently has large-scale internetworking become popular.
Routing Components
Routing involves two basic activities: determining optimal routing paths and transporting information groups (typically called packets) through an internetwork. In the context of the routing process, the latter of these is referred to as packet switching. Although packet switching is relatively straightforward, path determination can be very complex.
Path Determination
Routing protocols use metrics to evaluate what path will be the best for a packet to travel. A metric is a standard of measurement, such as path bandwidth, that is used by routing algorithms to determine the optimal path to a destination. To aid the process of path determination, routing algorithms initialize and maintain routing tables, which contain route information. Route information varies depending on the routing algorithm used.
Routing algorithms fill routing tables with a variety of information. Destination/next hop associations tell a router that a particular destination can be reached optimally by sending the packet to a particular router representing the "next hop" on the way to the final destination. When a router receives an incoming packet, it checks the destination address and attempts to associate this address with a next hop. Figure 5-1 depicts a sample destination/next hop routing table.
Figure 5-1 Destination/Next Hop Associations Determine the Data's Optimal Path
Routing tables also can contain other information, such as data about the desirability of a path. Routers compare metrics to determine optimal routes, and these metrics differ depending on the design of the routing algorithm used. A variety of common metrics will be introduced and described later in this chapter.
Routers communicate with one another and maintain their routing tables through the transmission of a variety of messages. The routing update message is one such message that generally consists of all or a portion of a routing table. By analyzing routing updates from all other routers, a router can build a detailed picture of network topology. A link-state advertisement, another example of a message sent between routers, informs other routers of the state of the sender's links. Link information also can be used to build a complete picture of network topology to enable routers to determine optimal routes to network destinations.
Switching
Switching algorithms is relatively simple; it is the same for most routing protocols. In most cases, a host determines that it must send a packet to another host. Having acquired a router's address by some means, the source host sends a packet addressed specifically to
a router's physical (Media Access Control [MAC]-layer) address, this time with the protocol (network layer) address of the destination host.
As it examines the packet's destination protocol address, the router determines that it either knows or does not know how to forward the packet to the next hop. If the router does not know how to forward the packet, it typically drops the packet. If the router knows how to forward the packet, however, it changes the destination physical address to that of the next hop and transmits the packet.
The next hop may be the ultimate destination host. If not, the next hop is usually another router, which executes the same switching decision process. As the packet moves through the internetwork, its physical address changes, but its protocol address remains constant, as illustrated in Figure 5-2.
The preceding discussion describes switching between a source and a destination end system. The International Organization for Standardization (ISO) has developed a hierarchical terminology that is useful in describing this process. Using this terminology, network devices without the capability to forward packets between subnetworks are called end systems (ESs), whereas network devices with these capabilities are called intermediate systems (ISs). ISs are further divided into those that can communicate within routing domains (intradomain ISs) and those that communicate both within and between routing domains (interdomain ISs). A routing domain generally is considered a portion of an internetwork under common administrative authority that is regulated by a particular set of administrative guidelines. Routing domains are also called autonomous systems. With certain protocols, routing domains can be divided into routing areas, but intradomain routing protocols are still used for switching both within and between areas.
Figure 5-2 Numerous Routers May Come into Play During the Switching Process
Routing Algorithms
Routing algorithms can be differentiated based on several key characteristics. First, the particular goals of the algorithm designer affect the operation of the resulting routing protocol. Second, various types of routing algorithms exist, and each algorithm has a different impact on network and router resources. Finally, routing algorithms use a variety of metrics that affect calculation of optimal routes. The following sections analyze these routing algorithm attributes.
Design Goals
Routing algorithms often have one or more of the following design goals:
•Optimality
•Simplicity and low overhead
•Robustness and stability
•Rapid convergence
•Flexibility
Optimality refers to the capability of the routing algorithm to select the best route, which depends on the metrics and metric weightings used to make the calculation. For example, one routing algorithm may use a number of hops and delays, but it may weigh delay more heavily in the calculation. Naturally, routing protocols must define their metric calculation algorithms strictly.
Routing algorithms also are designed to be as simple as possible. In other words, the routing algorithm must offer its functionality efficiently, with a minimum of software and utilization overhead. Efficiency is particularly important when the software implementing the routing algorithm must run on a computer with limited physical resources.
Routing algorithms must be robust, which means that they should perform correctly in
the face of unusual or unforeseen circumstances, such as hardware failures, high load conditions, and incorrect implementations. Because routers are located at network junction points, they can cause considerable problems when they fail. The best routing algorithms are often those that have withstood the test of time and that have proven stable under a variety of network conditions.
In addition, routing algorithms must converge rapidly. Convergence is the process of agreement, by all routers, on optimal routes. When a network event causes routes to either go down or become available, routers distribute routing update messages that permeate networks, stimulating recalculation of optimal routes and eventually causing all routers to agree on these routes. Routing algorithms that converge slowly can cause routing loops or network outages.
In the routing loop displayed in Figure 5-3, a packet arrives at Router 1 at time t1. Router 1 already has been updated and thus knows that the optimal route to the destination calls for Router 2 to be the next stop. Router 1 therefore forwards the packet to Router 2, but because this router has not yet been updated, it believes that the optimal next hop is Router 1. Router 2 therefore forwards the packet back to Router 1, and the packet continues to bounce back and forth between the two routers until Router 2 receives its routing update or until the packet has been switched the maximum number of times allowed.
Figure 5-3 Slow Convergence and Routing Loops Can Hinder Progress
Routing algorithms should also be flexible, which means that they should quickly and accurately adapt to a variety of network circumstances. Assume, for example, that a network segment has gone down. As many routing algorithms become aware of the problem, they will quickly select the next-best path for all routes normally using that segment. Routing algorithms can be programmed to adapt to changes in network bandwidth, router queue size, and network delay, among other variables.
Algorithm Types
Routing algorithms can be classified by type. Key differentiators include these:
•Static versus dynamic
•Single-path versus multipath
•Flat versus hierarchical
•Host-intelligent versus router-intelligent
•Intradomain versus interdomain
•Link-state versus distance vector
Static Versus Dynamic
Static routing algorithms are hardly algorithms at all, but are table mappings established by the network administrator before the beginning of routing. These mappings do not change unless the network administrator alters them. Algorithms that use static routes are simple to design and work well in environments where network traffic is relatively predictable and where network design is relatively simple.
Because static routing systems cannot react to network changes, they generally are considered unsuitable for today's large, constantly changing networks. Most of the dominant routing algorithms today are dynamic routing algorithms, which adjust to changing network circumstances by analyzing incoming routing update messages. If the message indicates that a network change has occurred, the routing software recalculates routes and sends out new routing update messages. These messages permeate the network, stimulating routers to rerun their algorithms and change their routing tables accordingly.
Dynamic routing algorithms can be supplemented with static routes where appropriate. A router of last resort (a router to which all unroutable packets are sent), for example, can be designated to act as a repository for all unroutable packets, ensuring that all messages are at least handled in some way.
Single-Path Versus Multipath
Some sophisticated routing protocols support multiple paths to the same destination. Unlike single-path algorithms, these multipath algorithms permit traffic multiplexing over multiple lines. The advantages of multipath algorithms are obvious: They can provide substantially better throughput and reliability. This is generally called load sharing.
Flat Versus Hierarchical
Some routing algorithms operate in a flat space, while others use routing hierarchies. In a flat routing system, the routers are peers of all others. In a hierarchical routing system, some routers form what amounts to a routing backbone. Packets from nonbackbone routers travel to the backbone routers, where they are sent through the backbone until they reach the general area of the destination. At this point, they travel from the last backbone router through one or more nonbackbone routers to the final destination.
Routing systems often designate logical groups of nodes, called domains, autonomous systems, or areas. In hierarchical systems, some routers in a domain can communicate with routers in other domains, while others can communicate only with routers within their domain. In very large networks, additional hierarchical levels may exist, with routers at the highest hierarchical level forming the routing backbone.
The primary advantage of hierarchical routing is that it mimics the organization of most companies and therefore supports their traffic patterns well. Most network communication occurs within small company groups (domains). Because intradomain routers need to know only about other routers within their domain, their routing algorithms can be simplified, and, depending on the routing algorithm being used, routing update traffic can be reduced accordingly.
Host-Intelligent Versus Router-Intelligent
Some routing algorithms assume that the source end node will determine the entire route. This is usually referred to as source routing. In source-routing systems, routers merely act as store-and-forward devices, mindlessly sending the packet to the next stop.
Other algorithms assume that hosts know nothing about routes. In these algorithms, routers determine the path through the internetwork based on their own calculations. In the first system, the hosts have the routing intelligence. In the latter system, routers have the routing intelligence.
Intradomain Versus Interdomain
Some routing algorithms work only within domains; others work within and between domains. The nature of these two algorithm types is different. It stands to reason, therefore, that an optimal intradomain-routing algorithm would not necessarily be an optimal interdomain-routing algorithm.
Link-State Versus Distance Vector
Link-state algorithms (also known as shortest path first algorithms) flood routing information to all nodes in the internetwork. Each router, however, sends only the portion of the routing table that describes the state of its own links. In link-state algorithms, each router builds a picture of the entire network in its routing tables. Distance vector algorithms (also known as Bellman-Ford algorithms) call for each router to send all or some portion of its routing table, but only to its neighbors. In essence, link-state algorithms send small updates everywhere, while distance vector algorithms send larger updates only to neighboring routers. Distance vector algorithms know only about their neighbors.
Because they converge more quickly, link-state algorithms are somewhat less prone to routing loops than distance vector algorithms. On the other hand, link-state algorithms require more CPU power and memory than distance vector algorithms. Link-state algorithms, therefore, can be more expensive to implement and support. Link-state protocols are generally more scalable than distance vector protocols.
Routing Metrics
Routing tables contain information used by switching software to select the best route. But how, specifically, are routing tables built? What is the specific nature of the information that they contain? How do routing algorithms determine that one route is preferable to others?
Routing algorithms have used many different metrics to determine the best route. Sophisticated routing algorithms can base route selection on multiple metrics, combining them in a single (hybrid) metric. All the following metrics have been used:
•Path length
•Reliability
•Delay
•Bandwidth
•Load
•Communication cost
Path length is the most common routing metric. Some routing protocols allow network administrators to assign arbitrary costs to each network link. In this case, path length is the sum of the costs associated with each link traversed. Other routing protocols define hop count, a metric that specifies the number of passes through internetworking products, such as routers, that a packet must take en route from a source to a destination.
Reliability, in the context of routing algorithms, refers to the dependability (usually described in terms of the bit-error rate) of each network link. Some network links might go down more often than others. After a network fails, certain network links might be repaired more easily or more quickly than other links. Any reliability factors can be taken into account in the assignment of the reliability ratings, which are arbitrary numeric values usually assigned to network links by network administrators.
Routing delay refers to the length of time required to move a packet from source to destination through the internetwork. Delay depends on many factors, including the bandwidth of intermediate network links, the port queues at each router along the way, network congestion on all intermediate network links, and the physical distance to be traveled. Because delay is a conglomeration of several important variables, it is a common and useful metric.
Bandwidth refers to the available traffic capacity of a link. All other things being equal, a 10-Mbps Ethernet link would be preferable to a 64-kbps leased line. Although bandwidth is a rating of the maximum attainable throughput on a link, routes through links with greater bandwidth do not necessarily provide better routes than routes through slower links. For example, if a faster link is busier, the actual time required to send a packet to the destination could be greater.
Load refers to the degree to which a network resource, such as a router, is busy. Load can be calculated in a variety of ways, including CPU utilization and packets processed per second. Monitoring these parameters on a continual basis can be resource-intensive itself.
Communication cost is another important metric, especially because some companies may not care about performance as much as they care about operating expenditures. Although line delay may be longer, they will send packets over their own lines rather than through the public lines that cost money for usage time.
Network Protocols
Routed protocols are transported by routing protocols across an internetwork. In general, routed protocols in this context also are referred to as network protocols. These network protocols perform a variety of functions required for communication between user applications in source and destination devices, and these functions can differ widely among protocol suites. Network protocols occur at the upper five layers of the OSI reference model: the network layer, the transport layer, the session layer, the presentation layer, and the application layer.
Confusion about the terms routed protocol and routing protocol is common. Routed protocols are protocols that are routed over an internetwork. Examples of such protocols are the Internet Protocol (IP), DECnet, AppleTalk, Novell NetWare, OSI, Banyan VINES, and Xerox Network System (XNS). Routing protocols, on the other hand, are protocols that implement routing algorithms. Put simply, routing protocols are used by intermediate systems to build tables used in determining path selection of routed protocols. Examples of these protocols include Interior Gateway Routing Protocol (IGRP), Enhanced Interior Gateway Routing Protocol (Enhanced IGRP), Open Shortest Path First (OSPF), Exterior Gateway Protocol (EGP), Border Gateway Protocol (BGP), Intermediate System-to-Intermediate System (IS-IS), and Routing Information Protocol (RIP). Routed and routing protocols are discussed in detail later in this book.
Aticle Privacy Statement
Aticle Privacy Statement
What follows is the Privacy Statement for all aticle websites (a.k.a. blogs) including all the websites run under the http://article-tkj.blogspot.com domain.
Please read this statement regarding our blogs. If you have questions please ask us via our contact form.
Email Addresses
You may choose to add your email address to our contact list via the forms on our websites. We agree that we will never share you email with any third party and that we will remove your email at your request. We don’t currently send advertising via email, but in the future our email may contain advertisements and we may send dedicated email messages from our advertisers without revealing your email addresses to them. If you have any problem removing your email address please contact us via our contact form.
Ownership of Information
Article is the sole owner of any information collected on our websites.
Comments/Message Boards
Most Aticle ontain comment sections (a.k.a. message boards). We do not actively monitor these comments and the information on them is for entertainment purposes only. If we are alerted to something we deem inappropriate in any way, we may delete it at our discretion. We use email validation on most of our message boards in order to reduce “comment spam.” These email addresses will not be shared with any third party.
Cookies
Currently we assign cookies to our readers in order to save their preferences. This data is not shared with any third party. Accessing our websites is not dependent on accepting cookies and all major browsers allow you to disable cookies if you wish.
Third Party Cookies
Many of our advertisers use cookies in order to determine the number of times you have seen an advertisement. This is done to limit the number times you are shown the same advertisement. Aticle does not have access to this data.
Traffic Reports
Our industry-standard traffic reporting records IP addresses, Internet service provider information, referrer strings, browser types and the date and time pages are loaded. We use this information in the aggregate only to provide traffic statistics to advertisers and to figure out which features and editorials are most popular.
Legal proceedings
We will make every effort to preserve user privacy but Article may need to disclose information when required by law.
Business Transitions
If Article is acquired by or merges with another firm, the assets of our websites, including personal information, will likely be transferred to the new firm.
Links
Article websites frequently link to other websites. We are not responsible for the content or business practices of these websites. When you leave our websites we encourage you to read the destination site’s privacy policy. This privacy statement applies solely to information collected by Article
Notification of Changes
When Article makes changes to this privacy policy we will post those changes here.
Contact Information
If you have any questions regarding our privacy policy, please contact us.
What follows is the Privacy Statement for all aticle websites (a.k.a. blogs) including all the websites run under the http://article-tkj.blogspot.com domain.
Please read this statement regarding our blogs. If you have questions please ask us via our contact form.
Email Addresses
You may choose to add your email address to our contact list via the forms on our websites. We agree that we will never share you email with any third party and that we will remove your email at your request. We don’t currently send advertising via email, but in the future our email may contain advertisements and we may send dedicated email messages from our advertisers without revealing your email addresses to them. If you have any problem removing your email address please contact us via our contact form.
Ownership of Information
Article is the sole owner of any information collected on our websites.
Comments/Message Boards
Most Aticle ontain comment sections (a.k.a. message boards). We do not actively monitor these comments and the information on them is for entertainment purposes only. If we are alerted to something we deem inappropriate in any way, we may delete it at our discretion. We use email validation on most of our message boards in order to reduce “comment spam.” These email addresses will not be shared with any third party.
Cookies
Currently we assign cookies to our readers in order to save their preferences. This data is not shared with any third party. Accessing our websites is not dependent on accepting cookies and all major browsers allow you to disable cookies if you wish.
Third Party Cookies
Many of our advertisers use cookies in order to determine the number of times you have seen an advertisement. This is done to limit the number times you are shown the same advertisement. Aticle does not have access to this data.
Traffic Reports
Our industry-standard traffic reporting records IP addresses, Internet service provider information, referrer strings, browser types and the date and time pages are loaded. We use this information in the aggregate only to provide traffic statistics to advertisers and to figure out which features and editorials are most popular.
Legal proceedings
We will make every effort to preserve user privacy but Article may need to disclose information when required by law.
Business Transitions
If Article is acquired by or merges with another firm, the assets of our websites, including personal information, will likely be transferred to the new firm.
Links
Article websites frequently link to other websites. We are not responsible for the content or business practices of these websites. When you leave our websites we encourage you to read the destination site’s privacy policy. This privacy statement applies solely to information collected by Article
Notification of Changes
When Article makes changes to this privacy policy we will post those changes here.
Contact Information
If you have any questions regarding our privacy policy, please contact us.
VBScript open folder
'==========================================================================
'
' VBScript: BrowseFolderSUB.vbs
'Author: Kenneth Værsland
'Date 10/12/2008
' NAME: BrowseFolderSUB.vbs
'==========================================================================
subGetFolder
Sub subGetFolder
Dim objShell, objFOlder, objFolderItem, objPath
Const windowHandle = 0
Const folderOnly = 0
const folderAndFiles = &H4000&
Set objShell = CreateObject("Shell.Application")
Set objFOlder = objShell.BrowseForFolder(windowHandle, _
"Select a folder:", folderOnly)
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
End Sub
'==========================================================================
'Author: Kenneth Værsland
'Date 10/12/2008
' Name: BrowseFolderListFiles.vbs
'==========================================================================
Option Explicit
On Error Resume Next
Dim FolderPath 'Path to the folder to be searched for files
Dim objFSO 'The fileSystemObject
Dim objFolder 'The folder object
Dim colFiles 'Collection of files from files method
Dim objFile 'individual file object
Dim strOUT 'Single output variable
subCheckWscript 'Ensures script is running under wscript
subGetFolder 'Calls the browseForFOlder method
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set colFiles = objFolder.Files
For Each objFile in colFiles
strOUT = strOUT & objFile.Name & vbTab & objFile.Size _
& " bytes" & VbCrLf
Next
WScript.Echo strOUT
' ****** subs below ******
Sub subCheckWscript
If UCase(Right(WScript.FullName, 11)) = "CSCRIPT.EXE" Then
WScript.Echo "This script must be run under WScript."
WScript.Quit
End If
End Sub
Sub subGetFolder
Dim objShell, objFOlder, objFolderItem
Const windowHandle = 0
Const folderOnly = 0
const folderAndFiles = &H4000&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(windowHandle, _
"Select a folder:", folderOnly)
Set objFolderItem = objFolder.Self
FolderPath = objFolderItem.Path
End Sub
'
' VBScript: BrowseFolderSUB.vbs
'Author: Kenneth Værsland
'Date 10/12/2008
' NAME: BrowseFolderSUB.vbs
'==========================================================================
subGetFolder
Sub subGetFolder
Dim objShell, objFOlder, objFolderItem, objPath
Const windowHandle = 0
Const folderOnly = 0
const folderAndFiles = &H4000&
Set objShell = CreateObject("Shell.Application")
Set objFOlder = objShell.BrowseForFolder(windowHandle, _
"Select a folder:", folderOnly)
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
End Sub
'==========================================================================
'Author: Kenneth Værsland
'Date 10/12/2008
' Name: BrowseFolderListFiles.vbs
'==========================================================================
Option Explicit
On Error Resume Next
Dim FolderPath 'Path to the folder to be searched for files
Dim objFSO 'The fileSystemObject
Dim objFolder 'The folder object
Dim colFiles 'Collection of files from files method
Dim objFile 'individual file object
Dim strOUT 'Single output variable
subCheckWscript 'Ensures script is running under wscript
subGetFolder 'Calls the browseForFOlder method
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set colFiles = objFolder.Files
For Each objFile in colFiles
strOUT = strOUT & objFile.Name & vbTab & objFile.Size _
& " bytes" & VbCrLf
Next
WScript.Echo strOUT
' ****** subs below ******
Sub subCheckWscript
If UCase(Right(WScript.FullName, 11)) = "CSCRIPT.EXE" Then
WScript.Echo "This script must be run under WScript."
WScript.Quit
End If
End Sub
Sub subGetFolder
Dim objShell, objFOlder, objFolderItem
Const windowHandle = 0
Const folderOnly = 0
const folderAndFiles = &H4000&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(windowHandle, _
"Select a folder:", folderOnly)
Set objFolderItem = objFolder.Self
FolderPath = objFolderItem.Path
End Sub
VBScript
VBScript
VBScript (short for Visual Basic Scripting Edition) is an Active Scripting language developed by Microsoft. The language's syntax reflects its history as a limited variation of Microsoft's Visual Basic programming language.
VBScript is installed by default in every desktop release of Microsoft Windows since Windows 98,[1] and may or may not be included with Windows CE depending on the configuration and purpose of the device it is running on. It initially gained support from Windows administrators seeking an automation tool more powerful than the batch language first developed in the late 1970s.
A VBScript script must be executed within a host environment, of which there are several provided on a standard install of Microsoft Windows (Windows Script Host, Internet Explorer). Additionally, The VBScript hosting environment is embeddable in other programs, through technologies such as the Microsoft Script control (msscript.ocx).
Contents
[hide]
• 1 History
• 2 Uses
• 3 Functionality
• 4 See also
• 5 References
• 6 External links
History
VBScript began as part of the Microsoft Windows Script Technologies, which were targeted at web developers initially and were launched in 1996. During a period of just over two years, the VBScript and JScript languages advanced from version 1.0 to 2.0 (the latter was later renamed 5.0) and over that time system administrators noticed it and began using it. In version 5.0, the functionality of VBScript was increased with new features such as regular expressions, classes, the With statement,[2] Eval/Execute/ExecuteGlobal functions to evaluate and execute script commands built during the execution of another script, a function-pointer system via GetRef(), and Distributed COM (DCOM) support.
In 5.5, "Submatches"[3] were added to the regular expression class in VBScript to finally allow VBScript script authors to capture the text within the expression's groups. That capability before was only possible through the JScript member of the Microsoft ActiveX Scripting family.
As of 2008, no new functionality will be added to the VBScript language, which has been superseded by Windows PowerShell. However, it will continue to be shipped with future releases of Microsoft Windows, as will other components of the ActiveX Scripting Family (such as JScript). Additionally, support will continue due to the amount of code written in it and because it is still considered a useful tool for some tasks.
The language engine is currently being maintained by Microsoft's Sustaining Engineering Team, which is responsible for bug fixes and security enhancements.
Uses
When employed in Microsoft Internet Explorer, VBScript is similar in function to JavaScript, as a language to write functions that are embedded in or included from HTML pages and interact with the Document Object Model (DOM) of the page, to perform tasks not possible in HTML alone. Other web browsers such as Firefox, and Opera do not have built-in support for VBScript. This means that where client-side script is required on a web site, developers almost always use JavaScript for cross-browser compatibility.
Besides client-side web development, VBScript is used for server-side processing of web pages, most notably with Microsoft Active Server Pages (ASP). The ASP engine and type library, asp.dll, invokes vbscript.dll to run VBScript scripts. VBScript that is embedded in an ASP page is contained within <% and %> context switches. The following example of an ASP page with VBScript displays the current time in 24-hour format (Note that an '=' sign occurring after a context switch (<%) is short-hand for a call to Write() method of the Response object).
<% Option Explicit
%>
VBScript Example
<%
'Grab current time from Now() function.
Dim timeValue
timeValue = Now %>
The time, in 24-hour format, is <%=Hour(timeValue)%>:<%=Minute(timeValue)%>:<%=Second(timeValue)%>.
VBScript can also be used to create applications that run directly on a person's computer running Microsoft Windows. The simplest example of this is a script that makes use of the Windows Script Host (WSH) environment. Such a script is usually in a stand-alone file with the file extension .vbs. The script can be invoked in two ways. Wscript.exe is used to display output and receive input in through a GUI, such as dialog and input boxes. Cscript.exe is used in a command line environment.
VBScript .vbs files can be included in two other types of scripting files: .wsf files, which are styled after XML; and .hta files, which are styled after HTML. .wsf files can be executed using wscript.exe or cscript.exe, just like .vbs files, and .wsf files can include multiple .vbs files. As a result .wsf files provide a means for code reuse: one can write a library of classes or functions in one or more .vbs files, and include those files in one or more .wsf files to use and reuse that functionality in a modular way.
Another employment of VBScript is the HTML Application, or HTA (file extension .hta). In an HTA, HTML is used for the user interface, and a scripting language such as VBScript is used for the program logic. HTAs run inside of mshta.exe, which is a 'Trusted Application Environment' provided by Internet Explorer. The 'Trusted Application Environment', implies that HTAs do not suffer the restrictions applied to applications running in the web or intranet zone, such as accessing local files or network paths. Although HTAs run in this 'trusted' environment, querying Active Directory can be subject to Internet Explorer Zone logic and associated error messages.
VBScript (and JScript) can be used in a .wsc file to create a Windows Script Component - an ActiveX-enabled script class that can be invoked by other COM-enabled applications.[4]
Lastly, VBScript has been adopted as the internal scripting language for some embedded applications, such as industrial operator interfaces and human machine interfaces.[citation needed]
Functionality
As-is, VBScript provides functions and sub-routines, basic date/time, string manipulation, math, user interaction, error handling, and regular expressions. Additional functionality can be added through the use of ActiveX technologies. File system management, file modification, and streaming text operations can be achieved with the Scripting Runtime Library scrrun.dll. Binary file and memory I/O is provided by the "ADODB.Stream" class, which can also be used as a string builder (since a high amount of VBScript string concatenation is costly due to constant memory re-allocation), and can be used to convert an array of bytes to a string and vice versa. Database access is made possible through ActiveX Data Objects (ADO), and the IIS Metabase can be manipulated using the GetObject() function with sufficient permissions (useful for creating and destroying sites and virtual directories). Additionally, XML files and schemas can be manipulated with the Microsoft XML Library Application Programming Interfaces (msxml6.dll, msxml3.dll), which also can be used to retrieve content from the World Wide Web via the XMLHTTP and ServerXMLHTTP objects (class strings "MSXML2.XMLHTTP.6.0" and "MSXML2.ServerXMLHTTP.6.0").
See also
• JScript
• JavaScript
• PHP
• JScript.NET
• Windows Script File
• HTML Components
References
1. "WSH Version Information". Microsoft (2008). Retrieved on 2008-04-02.
2. "Visual Basic Scripting Edition:With Statement (VBScript)". Microsoft (2008). Retrieved on 2008-04-02.
3. "Visual Basic Scripting Edition: SubMatches Collection". Microsoft (2008). Retrieved on 2008-04-02.
4. "Introducing Windows Script Components". Microsoft (2008). Retrieved on 2008-04-02.
External links
• VBScript in the Microsoft Developer Network
• Windows Script 5.6 Documentation
VBScript (short for Visual Basic Scripting Edition) is an Active Scripting language developed by Microsoft. The language's syntax reflects its history as a limited variation of Microsoft's Visual Basic programming language.
VBScript is installed by default in every desktop release of Microsoft Windows since Windows 98,[1] and may or may not be included with Windows CE depending on the configuration and purpose of the device it is running on. It initially gained support from Windows administrators seeking an automation tool more powerful than the batch language first developed in the late 1970s.
A VBScript script must be executed within a host environment, of which there are several provided on a standard install of Microsoft Windows (Windows Script Host, Internet Explorer). Additionally, The VBScript hosting environment is embeddable in other programs, through technologies such as the Microsoft Script control (msscript.ocx).
Contents
[hide]
• 1 History
• 2 Uses
• 3 Functionality
• 4 See also
• 5 References
• 6 External links
History
VBScript began as part of the Microsoft Windows Script Technologies, which were targeted at web developers initially and were launched in 1996. During a period of just over two years, the VBScript and JScript languages advanced from version 1.0 to 2.0 (the latter was later renamed 5.0) and over that time system administrators noticed it and began using it. In version 5.0, the functionality of VBScript was increased with new features such as regular expressions, classes, the With statement,[2] Eval/Execute/ExecuteGlobal functions to evaluate and execute script commands built during the execution of another script, a function-pointer system via GetRef(), and Distributed COM (DCOM) support.
In 5.5, "Submatches"[3] were added to the regular expression class in VBScript to finally allow VBScript script authors to capture the text within the expression's groups. That capability before was only possible through the JScript member of the Microsoft ActiveX Scripting family.
As of 2008, no new functionality will be added to the VBScript language, which has been superseded by Windows PowerShell. However, it will continue to be shipped with future releases of Microsoft Windows, as will other components of the ActiveX Scripting Family (such as JScript). Additionally, support will continue due to the amount of code written in it and because it is still considered a useful tool for some tasks.
The language engine is currently being maintained by Microsoft's Sustaining Engineering Team, which is responsible for bug fixes and security enhancements.
Uses
When employed in Microsoft Internet Explorer, VBScript is similar in function to JavaScript, as a language to write functions that are embedded in or included from HTML pages and interact with the Document Object Model (DOM) of the page, to perform tasks not possible in HTML alone. Other web browsers such as Firefox, and Opera do not have built-in support for VBScript. This means that where client-side script is required on a web site, developers almost always use JavaScript for cross-browser compatibility.
Besides client-side web development, VBScript is used for server-side processing of web pages, most notably with Microsoft Active Server Pages (ASP). The ASP engine and type library, asp.dll, invokes vbscript.dll to run VBScript scripts. VBScript that is embedded in an ASP page is contained within <% and %> context switches. The following example of an ASP page with VBScript displays the current time in 24-hour format (Note that an '=' sign occurring after a context switch (<%) is short-hand for a call to Write() method of the Response object).
<% Option Explicit
%>
<%
'Grab current time from Now() function.
Dim timeValue
timeValue = Now %>
The time, in 24-hour format, is <%=Hour(timeValue)%>:<%=Minute(timeValue)%>:<%=Second(timeValue)%>.
VBScript can also be used to create applications that run directly on a person's computer running Microsoft Windows. The simplest example of this is a script that makes use of the Windows Script Host (WSH) environment. Such a script is usually in a stand-alone file with the file extension .vbs. The script can be invoked in two ways. Wscript.exe is used to display output and receive input in through a GUI, such as dialog and input boxes. Cscript.exe is used in a command line environment.
VBScript .vbs files can be included in two other types of scripting files: .wsf files, which are styled after XML; and .hta files, which are styled after HTML. .wsf files can be executed using wscript.exe or cscript.exe, just like .vbs files, and .wsf files can include multiple .vbs files. As a result .wsf files provide a means for code reuse: one can write a library of classes or functions in one or more .vbs files, and include those files in one or more .wsf files to use and reuse that functionality in a modular way.
Another employment of VBScript is the HTML Application, or HTA (file extension .hta). In an HTA, HTML is used for the user interface, and a scripting language such as VBScript is used for the program logic. HTAs run inside of mshta.exe, which is a 'Trusted Application Environment' provided by Internet Explorer. The 'Trusted Application Environment', implies that HTAs do not suffer the restrictions applied to applications running in the web or intranet zone, such as accessing local files or network paths. Although HTAs run in this 'trusted' environment, querying Active Directory can be subject to Internet Explorer Zone logic and associated error messages.
VBScript (and JScript) can be used in a .wsc file to create a Windows Script Component - an ActiveX-enabled script class that can be invoked by other COM-enabled applications.[4]
Lastly, VBScript has been adopted as the internal scripting language for some embedded applications, such as industrial operator interfaces and human machine interfaces.[citation needed]
Functionality
As-is, VBScript provides functions and sub-routines, basic date/time, string manipulation, math, user interaction, error handling, and regular expressions. Additional functionality can be added through the use of ActiveX technologies. File system management, file modification, and streaming text operations can be achieved with the Scripting Runtime Library scrrun.dll. Binary file and memory I/O is provided by the "ADODB.Stream" class, which can also be used as a string builder (since a high amount of VBScript string concatenation is costly due to constant memory re-allocation), and can be used to convert an array of bytes to a string and vice versa. Database access is made possible through ActiveX Data Objects (ADO), and the IIS Metabase can be manipulated using the GetObject() function with sufficient permissions (useful for creating and destroying sites and virtual directories). Additionally, XML files and schemas can be manipulated with the Microsoft XML Library Application Programming Interfaces (msxml6.dll, msxml3.dll), which also can be used to retrieve content from the World Wide Web via the XMLHTTP and ServerXMLHTTP objects (class strings "MSXML2.XMLHTTP.6.0" and "MSXML2.ServerXMLHTTP.6.0").
See also
• JScript
• JavaScript
• PHP
• JScript.NET
• Windows Script File
• HTML Components
References
1. "WSH Version Information". Microsoft (2008). Retrieved on 2008-04-02.
2. "Visual Basic Scripting Edition:With Statement (VBScript)". Microsoft (2008). Retrieved on 2008-04-02.
3. "Visual Basic Scripting Edition: SubMatches Collection". Microsoft (2008). Retrieved on 2008-04-02.
4. "Introducing Windows Script Components". Microsoft (2008). Retrieved on 2008-04-02.
External links
• VBScript in the Microsoft Developer Network
• Windows Script 5.6 Documentation
Subscribe to:
Posts (Atom)