Downloading Torrents inside LAN, behind proxy.

Posted by Shashank Krishna Tuesday, January 6, 2009


Ok guys, I am back with my daily ‘durty’ trick. Today we are going to download torrents inside a LAN where access to outside world is only through an HTTP proxy (most common scenario).


My next post is going to be about how to optimize your torrents downloads. So this post seemed logical as we moved form SSH to torrents. In our previous posts, we created a normal forward tunnel and a reverse tunnel and used them to unblock websites and to create a listening port inside LAN. This post revolves around dynamic tunnel. (A socks PROXY)

Trivia : Did you know Opera has an in-built torrent client.

Torrents is my preferred means of downloads. Torrents are a best helpful means for small websites to distribute big files. Everyone knows bandwidth costs money. Many open source Distros primarily rely upon torrents to be distributed. I believe its a perfect “Give and Take” model and is the future of distribution. Anyone can setup a tracker service and manage torrent distribution (unlike Gnutella and eDonkey).

Again, our aim is not to actually somehow download torrents at our workplaces. This would be illegal at most places. All we are discussing here is again power of SSH. Everything said/done here is for knowledge purpose.

OK. Lets download some torrents. Again, this post assumes that you have already set up your infrastructure from my previous post. This means, your are listening well on port 443. Please remember that this is our port of choice as we are doing all communication over HTTP proxy. Its a simple TIT for TAT solution. ;)

OK, this one is pretty simple. All you have to do is, add one more tunnel to your existing session putty session. Create this tunnel as follows:

Source port: 23456 (Any, Your favorite number?)

Type = Dynamic. ( Note that last two times we created Local and Remote tunnels )

Putty config

Save session and open connection. We have just created a dynamic Socks proxy at port 23456.

Now open your preferred torrent client. I normally use

  • Azureus(Anywhere with lot of RAM,Overall best)
  • Deluge(Gnome, CPU issues)
  • Ktorrent(KDE)
  • uTorrent (Anywhere, Best client for less RAM).

Now open your client options and browse to connections settings and specify a socks proxy to be used. Make sure, you specify to use socks proxy even for peer 2 peer communication if such setting is there.

Done!! :) Grab the torrent file and load it in. Give that grim smile 8) and enjoy.

Important for half download speeds: Make sure that you keep torrent upload rate as low as possible while doing this, because whatever is being downloaded at home is finally being uploaded to your office connection. For e.g. if your bandwidth is 256kbps upstream. And you are uploading torrents at 15KBps, you can only download torrents at 15KBps at office. Simple maths. Also keeping very low upload speeds would also deteriorate download speeds. So for e.g., keep upload speed at 5KBps, and you will easily get 25KBps for download at office on a 256kpbs bandwidth.

You are all welcome to posts your comments/questions on SSH series of post (3 of them). Also let me know any future topics of discussions.



Share/Save/Bookmark
Subscribe

Get Vista's Best Features in XP

Posted by Shashank Krishna Monday, January 5, 2009



Despite the fact that most of you prefer XP to Vista and would rather Microsoft extended XP's shelf-life, several new and improved features available in Vista would be great to have in XP. This new functionality may not be enough to get you to switch to Vista, but that doesn't mean you're out of luck. Let's take a look at a few ways you can incorporate Windows Vista's best features into your current XP PC for free.

We're going to focus on Vista's small and large features that are missing from XP, separated into three categories: applications, functional, and aesthetic (e.g., transparency is aesthetic, the new start menu search is functional). This list is not exhaustive, but it does cover the features readers feel make Vista worth it.

Bring Vista's Best New and Improved Apps to XP

First, aside from some of the small operating system improvements we'll go into below, Vista also bundles up a few new and improved applications worth mentioning.

breadcrumbs.pngA Better Explorer: Windows Explorer is one of the most improved applications in Vista, thanks to added features like breadcrumb navigation, better file previews, and more. There are a few add-ons that add some of these better functional adjustments to Explorer, but in general XP users might want to consider replacing XP's Explorer altogether with something like Xplorer2 (original post) or significantly beefing it up with a tool like QT TabBar (original post). You can also get that saucy breadcrumb navigation alone with Explorer Breadcrumbs (original post).

truecrypt.pngEncrypt Your Hard Drive: Some versions of Vista—toward the Ultimate end of the scale—come with a new drive encryption software called BitLocker built in. If you're keen on security and encryption but you want to stick with XP, check out the free, open source TrueCrypt (original post). If you need a little help getting started, check out our guide to encrypting data with TrueCrypt.

snipping-tool.pngTake Quick and Easy Screenshots: PrtScrn has been around forever, but it's never been the most user-friendly way to get a screenshot. In Vista, Microsoft threw in a screenshot utility called the Snipping Tool. Fact is, if better screenshots are important to you, there are gobs of excellent free screenshot apps available for XP like Screenshot Captor (original post), Clip2Net (original post), and Jing (original post), among many others.

Bring Vista's Best Functional Features to XP

winflip.pngTask-Switching à la Flip 3D: Vista's Flip 3D is like Alt-Tab on steroids, displaying full previews of each window as you move through it. To a large extent it's eye candy, but it can also be really useful in finding the right window when you're switching from your keyboard. Freeware applications like Shock Aero 3D (original post) and WinFlip bring the same 3D shuffling (and then some, in the case of WinFlip) to your XP desktop.

vistart.pngIntegrated Start Menu Search and Launch: Dubbed Instant Search by Microsoft, this new feature adds a search box to the Windows Start menu for quick searching and launching of documents and applications. If you want to port this same functionality to XP, you can do so with apps like ViStart (original post) or Vista Start Menu (original post)—an extraordinarily beefed up version of the Windows Start menu. Then again, if you're not stuck on the notion of a search-and-launch box built directly into the Start menu, you can't go wrong with Launchy or Google Desktop Search.

Replace the Windows Sidebar: Third-party tools similar to Windows Sidebar and Gadgets pre-dated Vista, so you can trade in desktop real estate for the same functionality with SideSlide (original post) or the Google Desktop Sidebar.

xentient.pngLive Thumbnail Previews of Files: Vista does a nice job of providing thumbnail previews to most image files and even text files, and while XP does have similar functionality, it's not as advanced as Vista's. Freeware application Xentient Thumbnails (original post) creates live thumbnails for virtually all images, and if you want a more intimate look at the innards of text and other files without opening them, check out InfoTag Magic (original post).

eboostr.pngSpeed Up Your System with a Thumb Drive: Windows ReadyBoost speeds up your performance by using a USB thumb drive as system memory, and while nothing beats an actual RAM upgrade, XP users can check out eBoostr (original post) to bring the same functionality to XP.

Streamline Your File Renaming: Microsoft got smart in Vista and changed the behavior when you hit F2 to rename a file, selecting only the name of the file and leaving the extension alone. For a very simple integration of this feature into XP, check out the Better Rename utility. Alternately, if you feel like adding this feature and beefing up Windows Explorer on top of that, you can get the same renaming behavior in Xplorer2 (original post) or QT TabBar (original post).

preview.pngTaskbar Window Previews: If you like how Vista offers handy little thumbnail previews of windows when you hover over their taskbar item, freeware application Visual Tooltip (original post) brings the same goods to XP.


Give XP that Vista Look


aero.pngUltimately, despite all the little feature improvements Vista can throw your way, a new operating system's biggest selling point is often the eye candy—in Vista's case, Aero. There are a lot of tools available that can help you theme XP to look more like Vista, though often users of such applications see mixed results, so proceed at your own risk.

Probably the most comprehensive XP-to-Vista tweaker is the Vista Transformation Pack, which transforms everything from the Start menu and Control Panel to icons.

For a less full-on approach, you could try out skinning utility Uxtheme Patcher with one of several themes from art web site deviantART (like this one or this one) to make XP look and feel more like Vista.

Isn't There More to It Than That?

There are surely some under-the-hood changes in Vista that you won't get from these simple upgrades, but let's be honest: You care about the features, not the underlying code. And since you can get most of Vista's new features from the comfort of XP—and you can stick to XP as a quick, resource-light alternative to Vista—it looks like most of you won't be changing horses anytime soon.
If there's a Vista feature or an XP app you love that wasn't included in this list, let's hear about it in the comments. While you're getting the goods of Vista in XP, you may also want to take a look at how you can get the best of Firefox in Internet Explorer.



Share/Save/Bookmark
Subscribe

Make Vista run your way

Posted by Shashank Krishna


Make Vista run your way

A lot of people complain about one thing or the other in Vista. However, in many cases you can configure Vista to run more to your liking. Here’s a collection of links where you can find out how to tweak Vista:



Share/Save/Bookmark
Subscribe

Using the Registry Editor (windows)

Posted by Shashank Krishna


Using the Registry Editor (regedit.exe)

I don't expect the average home PC owner to be involved in manual Registry editing but there is no reason why advanced PC users should shy away from editing the Registry directly, provided that they follow the iron-clad rule of always backing up first. It is also advisable to restrict direct Registry editing to small changes. If more extensive changes are involved, a script or an editing interface like TweakUI or the Group Policy Editor is a preferable method for making edits. Many useful Registry edits consist of changing one or two values and are easily reversed.

Accessing the Registry Editor (Regedit)

The Registry Editor (also called regedit) is not listed in the Start menu or in All Programs. The utility is a single file regedit.exe and is located in the Windows folder on XP systems. It is accessed by using the Run line. Enter "regedit" and the utility will open. In Vista the utility is opened by entering "regedit.exe" in the Start Search line The Run line can also be used in Vista (but is no longer necessarily on the Start menu). As to be expected, an administrator account is required.

Regedit is a two-pane interface with keys in the left pane (key pane) and value names with the corresponding data in the right pane (value pane). The setup is not unlike Windows Explorer with keys analogous to folders and values analogous to files. (The basics of Registry structure are discussed on another page.) An example is shown in the figure below.

Figure 1, Registry Editor (Regedit)
Registry Editor

Also listed in the right or value pane is the type of data contained in a value. There are a number of formats that data can take and the usual ones that most PC users will encounter are given in Table I. I have omitted the more esoteric types. The three listed in the table constitute the vast majority of all Registry entries. Other data types are described at this Microsoft link.

Table I. Common Registry data types
Data type Description
REG_BINARY Binary data . Usually in hexadecimal notation. An example is 0xA8
REG_DWORD Double word (32 bits). Can be edited in either hexadecimal or decimal
REG_SZ A string. Figure 1 shows examples in the right pane.

Menus in Registry Editor

Regedit has some of the same menus that are so familiar throughout Windows. These can be seen near the top of Figure 1. Shown below are what two commonly used menus look like.

Figure 2. File menu Figure 3. Edit menu
Registry File Menu Registry Edit Menu

The File menu has the functions "Import" and "Export" that involve backup and restore. These are discussed on another page.

As you would expect, the "Edit" menu is where commands are located for making changes to the Registry. Keys and values can be deleted, added, or renamed. (Permission settings on keys can also be edited but that is an advanced subject beyond our scope.) Another two very useful functions are "Find..." and "Find Next". The Registry has thousands of keys and these search functions are very necessary. Unfortunately, the search function cannot find binary values or REG_DWORD entries. It searches key names, value names, and string data.

The bottom of he window for Regedit shows the path of the currently highlighted key as can be seen in Figure 1. The Edit menu also contains a useful entry "Copy Key Name" that sends the path of the key to the clipboard, Since path names can be quite long, this can be very useful.

Favorites menu in RegeditAnother menu that can be quite useful is "Favorites". If you find that there are is a certain key that you modify often, this key can be added to the "Favorites' list for easy access. The example of a "Favorites" menu shown on the right contains three favorites. Note the names have been chosen by this user and can be anything that is a convenient reminder. They actually refer to specific Registry keys, which can have very long path names.

Editing Registry Keys and Values

There are many useful adjustments to the Windows configuration or behavior that can be made by simple editing of the Registry. Unless you are a trained IT professional, you should probably limit Registry editing to one or two values at a time. I will limit this discussion to this type of straightforward scenario.

The first step in editing is always to back up the Registry. Also, back up the key you are working on. If you are a very careful worker, backing up just the key where editing is to be done may suffice but make a system restore point first anyway. To back up a key, open Regedit and highlight the key. Open the "file" menu and click "Export". For most cases. you will choose to export as a registration or REG file. This is a text file with extension .reg that is a copy of the highlighted Registry key. Save it to someplace safe. To restore a key with a REG file, right-click it and choose "Merge". On many machines the default left double-click on a REG file will also create a merge. I prefer to change the double-click action to "Edit" so that accidental mergers do not happen. Notice that I use the word "merge". Reg files do not replace keys but add to them, something to keep in mind. Anything extra that you may have added is not deleted. Some experienced PC users prefer to do any actual editing in the exported REG file and then to merge the edited file. This prevents accidentally doing something to the wrong key. Keep in mind that Regedit has no "undo" function. What's done is done.

If you are editing an entire key, you are very likely deleting it. (Careful! Back it up.) If you are making a number of changes, I suggest using a REG file and not editing in the Registry itself. I repeat, even power users should probably stick with editing one or two values. To delete a highlighted key, choose "Delete" from the "Edit" menu. Note that there is no recycle bin for deleted Registry keys or values. Deleted means gone to the great bit-bucket in the sky.

Dialog box for Edit StringFor the most part, direct Registry editing means changing a value. Highlight the value in question in the right-pane of Regedit. Then choose "Modify" from the "Edit" menu or right-click the value and choose "Modify" from the context menu. For strings, a box like the one shown on the right will open .As a specific example, consider the last value in the right-pane of Figure 1. The time that the system waits for a service to close at Shutdown is controlled by the entry for the value, WaitToKillServiceTimeout. The value is in milliseconds and the default is 20000 ( 20 seconds). To make things close up more quickly, you could change the value to 10000 (10 seconds). Or you might need to make it longer for certain systems. Enter the desired string in the line "Value data" and click OK.

Dialog box for DwordA great many Registry values are strings but another type of data that is common is the "dword". A slightly different box will appear if you are editing a REG_DWORD value. The figure on the left shows the appropriate box. Note that when entering a DWORD value, you need to specify the base for the number. Be careful to be sure that you have chosen correctly between hexadecimal and decimal. You can enter either but the number that you enter must correspond to the correct value for the chosen base. In the example here the decimal number "96" would have to be "60" if hexadecimal were picked for the base.



Share/Save/Bookmark
Subscribe

Registry Tweaks and Scripts

Posted by Shashank Krishna


Registry Tweaks and Scripts

Painless Registry Editing

You do not have to personally edit the Registry with Regedit in order to achieve some very useful system tweaks. There are some interfaces to do many of the configuration settings in Windows that are actually done in the Registry. Also, a great variety of simple scripts have been written to carry out many different types of system tweaks. The user never has to deal with the Registry directly. Windows is vastly configurable and all PC users should be aware of the many changes that can be made to suit individual tastes and usage patternsby taking advantage of the many easy ways to do edits to the Registry.

TweakUI

A worthwhile free utlity from Microsoft called TweakUI provides an interface that is easy to use and allows many useful system tweaks. The utility is part of a suite from Microsoft called PowerToys. The figure below shows some of the types of tweaks that are available. The settings that are available on TweakUI are explained in the interface.

TweakUI

Group Policy Editor

Windows XP Professional comes with a management console called the Group Policy Editor (GPE). Like many other management consoles, the GPE is not listed in Start-All Programs. To open it, go to Start-Run and enter "gpedit.msc" (without quotes). The figure below shows the GPE window. "

I have discussed the use of the GPE to make Registry changes with policy settings on the Computer Education site.

Registry (.reg) Files

Here is another way that the average PC user can easily carry out Registry edits without ever having to actually face the fearsome beast. Many useful configuration settings have already been done for you and made into little files with extension REG. Doing a Registry edit only involves right-clicking on the file and choosing "Merge" from the context menu that opens. There are numerous sources of REG files on the Web. I have discussed a number of them on this page. The ultimate site for REG files may be Kelly's Korner.

INF Files

Files with the extension INF can also be used to edit the Registry. They are much less common than REG files although I personally prefer them. I have discussed the details of using INF files in this article. I have also written some very simple INF files for carrying out useful Registry edits. Some examples are listed below and can be downloaded by clicking the links. The files are zipped. Download and unzip them anywhere convenient. Then right-click and choose "Install" from the right-click context menu. Note that the Registry change occurs silently. You may have to log off and log back on to see the results of the edit. The usual disclaimer holds: they are provided as is with no guarantees, The user is reponsible for the results of applying them.

VBScript

Scripts written in VBScript with extension VBS are another common source of edits for the Registry. Many examples are available on the Web. Kelly's Korner has many VBScripts as well as REG files





Share/Save/Bookmark
Subscribe

Command Line List and Reference

Posted by Shashank Krishna


The complete list of possible commands is quite large. Collected here is a selection of those that I believe are likely to be the most applicable to home PC use.

Many of the commands listed below are also discussed in more detail elsewhere on this site as is indicated by the link "details here". Most commands have switches that are not given in the table. For more information, open a command prompt and enter "commandname /?" (without quotes). Detailed information about these commands and a larger list is available at this Microsoft reference.

Selected list of commands
Command Description Example
assoc Displays or modifies file name extension associations. Used alone, displays a list of all the current file name associations details here
at Schedules commands and programs to run on a computer at a specified time and date. Requires the Schedule service. Superseded by schtasks
attrib Configures file attributes read only, hidden, system details here
bootcfg Used to repair or edit the boot.ini file details here
cd or chdir Displays the name of the current directory or changes the current folder cd folderpath
chkdsk Checks hard drives for errors. With switches,does repairs. details here
cls Clears the screen cls
copy Copies a file from one location to another copy somefile somefolder
del Deletes one or more files details here
dir Displays a list of a folder's files and subfolders details here
echo Used to display a message or to turn off/on messages in batch scripts echo message
exit Exits batch script or current command control exit
fc Compares two files and displays the differences between them fc file1 file2
for Runs a specified command for each item in a set details here
fsutil Displays and configures certain file system properties. A suite of various commands details here
ftype Displays or modifies file types used in file name extension associations details here
getmac Returns the media access control (MAC) address for your network card getmac
goto Directs the Windows command interpreter to a labeled line in a batch program details here
if Performs conditional processing in batch programs details here
ipconfig Displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration Protocol (DHCP) and Domain Name System (DNS) settings details here
md or mkdir Creates a directory (folder) or subdirectory (subfolder) details here
more Displays one screen of output at a time. Used with another command that has extensive output command |more
move Moves a file from one folder to another details here
net A suite of various networking and service commands details here
netsh Network services shell . Complex suite of commands. details here
netstat Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, statistics for the IP, ICMP, TCP, and UDP protocols details here
path Sets the command path in the PATH environment variable, which is the set of directories used to search for executable files details here
pathping Provides information about network performance and conditions at intermediate hops between a source and destination details here
pause Used in batch scripts pause
ping Checks connectivity to other networked computers, routers, or Internet sites details here
popd, pushd Changes the directory being referenced in a command prompt. Pushd changes the directory and stores the previous directory. Popd changes the current directory to the directory stored by the pushd command pushd somefolder
popd
powercfg Manages the power settings such as hibernation. Has numerous switches
reg Adds, changes, and displays registry entries. A suite of various commands details here
rd or rmdir Deletes a directory (folder) details here
ren or rename Changes the name of a file or a set of files details here
sc Used to obtain information about services and to configure them. A suite of various commands details here
schtasks Schedules commands and programs to run periodically or at a specific time
set Displays, sets, or removes environment variables details here and also here
sfc System file checker scans and verifies the versions of all protected system files sfc /scannow
shutdown Shuts down or restarts a computer details here
start Starts an application or opens a new command window details here
subst Associates a folder with a drive letter details here
systeminfo Displays detailed configuration information about a computer and its operating system systeminfo | more
taskkill Ends one or more tasks or processes details here
tasklist Displays a list of applications and services with their Process ID (PID) for all tasks running details here
tree Graphically displays the directory structure of a folder or drive tree somefolder
typeDisplays the contents of a text file type somefile.txt
xcopy Powerful command with many switches for copying and backing up files and folders details here


Share/Save/Bookmark
Subscribe

Configuring the Command Prompt Window

Posted by Shashank Krishna

Configuring the Command Prompt Window
The interface to the command shell can be customized in a number of ways and these are discussed.
The default settings for the window that displays a command prompt can be changed to suit individual preferences. Among the properties that can be changed are those that affect the appearance such as window size, background and foreground color, and font style. Others that affect operation such as the editing mode and command history buffer can also be configured.

The command prompt properties dialog

Changing the settings for the command prompt can be done through the properties dialog box. This can be reached in the menu that is opened by left-clicking the icon in the left-top corner or by right-clicking anywhere in the title bar at the top of a command prompt window. In the menu that opens choose "Properties". Figures 1 and 2 show the procedure.

Fig. 1. Menu for command window Fig. 2. Entry for properties dialog
Menu for command window  Entry for properties dialog

The properties dialog box contains four tabs. Each of these is discussed below.

Options tabOptions tab

The figure on the right shows the dialog box for the Options tab. Settings here include provision for configuring cursor size and window or full-screen display. The "Quick Edit" mode allows you to use the mouse to cut and paste text to and from the command window. You can also choose insert or overwriting for editing by checking or unchecking "Insert Mode".

Command History buffer

A new feature is the "Command History" buffer. This buffer stores the previous commands that you have entered so that you do not have to retype them (reminiscent of Doskey). The default value is 50 but can be made as large as 999 (remember that they do take RAM) . The up-and-down arrow keys can be used to navigate the previously entered commands. Alternatively, pressing the F7 key will display a pop-up window with a list of the commands.

Font tab

This tab is more or less self-explanatory. On most machines, there is a choice of two font faces, Raster (the default) and Lucinda Console. Lucinda Console is more versatile. A selection of font sizes is available. As is true in general about settings, changes in font can be made for the present window only or for all command windows with the same title.

Layout tab

The window size and position can be set here. There are also settings for the screen buffer size. This determines how many lines back that you can scroll.( Incidentally, this ability to scroll back to previous commands was not present in DOS. Once something was off the screen, you couldn't scroll back.)

Color tabColor tab

The dialog box for configuring colors is shown on the right. The default colors for a command window and its fonts are the old black and white combination. However, other color combinations are available. The colors for pop-up windows associated with the command window can also be configured. As shown in the figure on the right, colors can be changed by clicking on the appropriate choice or by entering numerical values in the 256 color RGB notation. In the figure, I have chosen a blue screen background with yellow screen text as illustration. Color changes can be made for the current screen only or applied to all command windows.

Screen colors can also be changed with the "color" command or a command-line switch directly modifying the command interpreter. Both these methods are discussed below.

It is also possible to have shortcuts that open the command line with more than one color scheme and this is discussed in the shortcut section below.

Apply changes to all command windowsApplying changes to all command windows

Note that changes apply to the current command window only unless you specify otherwise. When making configuration changes, you will be shown the dialog box on the right. To make changes stick after the current command session is closed, check the button by the entry, " Save properties for future windows with same title".

Properties sheet for command prompt shortcutConfiguring shortcuts for the command prompt

If you use the command prompt a great deal, you may want to place a shortcut on the desktop or in the Quick Launch bar. After creating the shortcut, you can configure the properties of the command window that it will open in much the same way as discussed above. Right-click the shortcut and choose "Properties" from the context menu. Four of the the tabs at the top of the properties sheet will be the same as those discussed above. They are marked in the figure on the right. You can apply whatever customization you like and it will apply only to command windows that are opened from this particular shortcut.


Apply shortcut propertiesAnother way to configure the properties of a particular shortcut is to apply the changes in a command window that has been opened with that shortcut. After configuring the changes to the open command window by the methods discussed in sections above, the dialog box shown on the right will open. Check the button by the entry, "Modify shortcut that started this window".

The "color" command

The screen colors can be configured from the command line itself with the command "color" followed by a two-digit hexadecimal number. The first digit determines the background and the second determines the text color. The table below shows the relationship between the hex numbers and colors.

Table I. Hexadecimal color codes
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White

For example the command "color 1E" will give a blue background with yellow text. Settings made this way apply only to the current session. Entering "color" with no argument will return the system to the starting colors.

Switches for the command interpreter cmd.exe

Another way to modify the behavior of the command prompt is to use switches with the command interpreter cmd.exe. The syntax for cmd.exe is:
cmd [[{/c|/k}] [/s] [/q] [/d] [{/a|/u}] [/t:fg] [/e:{on|off}] [/f:{on|off}] [/v:{on|off}] string]
Table II describes the parameters briefly. See the Windows Help and Support Center for more detail.

Table II. Switches for cmd.exe
Parameter Description
/c Carries out the command specified by string and then exits
/k Carries out the command specified by string and stays open
/s Modifies the treatment of string after/c or /k. See Windows Help for details
/q Turns the echo off. Default is echo on
/d Disables execution of AutoRun commands
/a Creates ANSI output (the default)
/u Creates Unicode output
/t:fg Sets the foreground f and background g colors. The hex codes for f and g are in Table I.
/e:on /e:off Enables or disables commands extensions. The default is "on"
/f:on /f:off Enables or disables file and directory name completion
/v:on /v:off Enables or disables delayed environment variable expansion
string Specifies the command you want to carry out



Share/Save/Bookmark
Subscribe

XP Commands that everybody can use

Posted by Shashank Krishna


Power deleting with the expanded "Del" command

The delete command “del” now has a switch “/s” that provides for deletions in subfolders. Thus the commanddel /s myfolder\* will delete all files in myfolder and all files in any subfolders of myfolder. Note the convenient asterisk wildcard “*”, which allows for multiple deletions in a single user operation. Together with the switch “/s”, a single “del” command can clean out Temp folders and do other useful housekeeping chores. Another switch "/f" will force the deletion of read-only files. If you are sure about what is being deleted, add the “/q” switch to run in quiet mode so you aren’t asked if you really want to delete for every single file. Because of its power, this extended del command has to be used carefully. Any files deleted this way do not go into the Recycle Bin but are permanently removed.

To delete only files with a particular extension EXT, use the commanddel /s myfolder\*.ext Note that this command will delete all files of a particular type in a folder and all its subfolders. One example of its use is to get rid of all temporary files with the extension TMP.

Enhanced management of folders (directories)

The command "rmdir" or its twin "rd" are also expanded compared to the old DOS version. To remove folders (directories), use “rmdir” (just “rd” will also work). Folders must be empty before they can be deleted. However, there is a switch “/s” for deleting subfolders and with this switch files are also deleted. It is like the old command "deltree". The command rd /s myfolder will remove "myfolder" and everything in it. Adding the switch /q for a "quiet" mode is also possible.

Options have also been added to the command for making folders. The command “mkdir” or “md” can now make a whole tree. For example, consider the commandmd new\new1\new2 This will create a folder “new” with a subfolder “new1” that in turn has a subfolder “new2”.

Xcopy- Powerful and versatile way to copy or back up files

For copying large numbers of files or backing up a large folder, the command line is often the fastest and easiest way to go. The command “xcopy” is a very useful and powerful command for this purpose. (The old DOS also had an “xcopy” command but it sometimes had trouble with long file names. The XP version has no such problems.) “xcopy” comes with an alphabet soup of assorted switches that give it great versatility for use as a file backup utility. Enter “xcopy /?” in a command prompt to see them all. For example with the switch “/d:[mm-dd-yyy]” only files changed after a given date are copied. A command that will copy all files from the folder myfolder that have changed since June 1, 2003 to the folder mybackup is given byxcopy myfolder mybackup /d:06-01-2003 If no date is specified the switch “/d” will copy all files that have changed at any time.As is true in general, if there are spaces in a name, the path and file name have to be enclosed in quotes. Adding the switch "/s" provides that subfolders and their contents will also be copied. Other switches provide for read-only and hidden files. Altogether, there are something like 27 command line options for xcopy. More information is on this page.

How to list files with "dir"

The "dir" command is not new but it remains one of the most useful for average PC users. If you have ever wanted to make a list of all the files contained in a particular folder, you will have discovered that the Windows GUI provides no easy way to do this. It is very straightforward, however, when using the command line. The command “dir myfolder” will list the files and folders contained in myfolder. Again, there are switches that provide for various modifications of the command. For example “/h” will show hidden files and “/s” will list the contents of sub-folders in addition to those of the main folder. Of course, the normal output of the command is to the screen. To output to a file instead of the screen, the command isdir myfolder >listmyfolder.txt where “>” is the redirection symbol. The file "listmyfolder.txt" will be created by the command. Output can also be redirected straight to a printer on the LPT1 port but I think it is better to first create a file and then print from there if hardcopy is desired. These lists can be a lot longer than you might think. (These days most printers are on USB, anyway.) This use of dir is also available in Windows 98/Me.

The dir command can also be used to list only files with a given extension. For exampledir myfolder\*.doc /s >listmyfolder.txt will list all Microsoft Word files in myfolder and its subfolders. This form of the command will also list all the directories and sub-directories. If you want a list of filenames only, add the switch /b. The filename will include the full path.

Renaming files with "ren"

Renaming a a large number of files can be tedious. The command ren (also written rename) is somewhat limited but its ability to use wild cards can sometimes be useful. The basic command is ren file1 file2 The renamed file has to stay in the same folder as the original; this command cannot move files to another folder. The wildcard capability can be used to change the extension of all files of a certain type. Thus ren *.txt *.doc will rename all text files to have a DOC extension.

Moving files

The command "move" takes a file from one folder and puts it in another. Its ability to use wild cards makes it useful for moving all the files of a given type to another location. A command of the typemove /y folder1\*.mp3 folder2\will move all MP3 files from folder1 to folder2. The switch " /y" is used if you want to prevent the system from asking if it should overwrite existing files of the same name. To prevent overwriting, use the switch "/-y".

Changing file attributes with "attrib"

In addition to their actual content, files also have a set of properties that characterize them (sometimes called metadata.) One set of these properties are the four attributes read-only, hidden, system, and archive. The archive attribute is primarily used in backup procedures but the other three can be encountered in various contexts. These attributes can be turned on or off with the command "attrib" and its switches. The great utility of this command is that it can act on subfolders with its switch "/s" and can use the wildcard "*". For example, to clear the read-only , system, and hidden attributes from a file use attrib -r -s -h somefile This operation is not uncommon when system files have to be edited. To restore the attributes the command is attrib +r +s +h somefile A common situation where it is desirable to clear the read-only attribute from many files is when files are copied from a CD. By default CD files are normally marked read-only. This can interfere with editing. To clear the read-only attribute from all files in a folder and its subfolders use attrib -r somefolder\*.* /s If you want to process all files of a certain type such as MP3, use attrib -r somefolder\*.mp3 /s

How to make your favorite folder easily accessible in Windows dialog boxes

Another older command that I find handy is "subst". There are certain folders that I use over and over and I like to have ready access to them. One way to do this is to use the command “subst” to assign a drive letter to a folder. Since drives are at the top of My Computer and any folder trees in browse lists, it makes the folder very easy to get to. To map the “Z:” drive to a folder "myfolder", entersubst z: myfolder Unless you are working from the parent folder of "myfolder" you will need the full path for it. The assignment only lasts until the user logs off or the computer is shut down so I have a one-line batch file in my Startup folder that reinstitutes the assignment.

Other commands

There are so many commands that we can only give the briefest sketches here. A list of some that I think might be useful on home computers is given here. I urge you to look into as many as possible since I feel you will be surprised at how useful some can be. For example, there are a whole host of commands for checking network functions and for use on the Internet. (Many have names that begin with “net…”) There are new ones as well as versions of the well-known commands such as “ping” and “tracert”. As more and more people have home networks, these commands are assuming greater significance to the average PC user. Go to this page for more discussion of some networking commands.

Useful command line programs in scripts

Average PC users are not always comfortable using the command line and I have used VBScripts to wrap some of the examples discussed above with an easy-to-use graphical interface. Description of the free scripts and instructions for their use and downloading are at a sister site.




Share/Save/Bookmark
Subscribe

Are You Planning on Quitting Facebook? Why?

@Flickr

www.flickr.com

About Me

My Photo
Shashank Krishna
Bangalore, up, India
nothin much to say.........doin B.tech in IIIT allahabad loves bloggingn hacking.... :) and loooves blogging
View my complete profile

ads2

topads