Running a command, applying changes and other Windows Techniques

If you frequently RUN Windows System Utilities and apply changes to your profile, then you may know most of the tips given here. If you are only starting out, then you definitely need to know these small tips that can make your life easier. These tips constitute a series. Please read all the series posts.


In this article, we will discuss the different ways by which we can RUN a Windows utility. In order to run a program directly (by typing its name in the RUN box) it should be in a folder specified in the PATH variable. We will come to the PATH variable in a later post. While one can always run a program by double clicking on it, there are always easier methods to do it. Using keyboard shortcuts is second nature to anyone who has been working with a computer for a reasonable amount of time.

The easiest and quickest way to run a program or command is to type it directly into the Start Menu of Windows 7. This trick will only work if the item is part of the start menu. For example, you can open the Command Prompt by typing “cmd” and pressing ENTER or you can open Microsoft Word by typing “Office Word” and pressing ENTER. Do remember the functionality is limited and the program that will start will be the first item that appears in the Search.

RUN a command using Quick Search
Running a Command using the Start Menu

Using WIN+R – Run

The most popular of all is the normal RUN dialog box method. You press WIN+R and then type in the command name into the box that appears. You can only run a program which can be found using the PATH system variable. (Type in “echo %PATH%” in a Command Prompt and see for yourself). You need to type the name of the program without the extension (the .exe part)

Running a command using the RUN dialog box.

Using the Command Prompt

You can run any command/program by typing in its name in the command prompt. The command prompt can be opened by typing “cmd” after pressing WIN+R or clicking on the “Command Prompt” icon under “START>>All Programs>>Accessories” The rules that apply for WIN+R applies here too.

Comamnd Prompt
Running a command from the command prompt.

From Task Manager

This is same as the RUN dialog method. You can see a similar box dialog if you open “File>>New Task” under task Manager. You can type in all the things you could do in a WIN+R dialog. Why do you need to use this method then? If Windows Explorer has crashed and you don’t know what to do, press ALT+CTRL+DEL and open the Task Manager. Now go to File>>New Task and type “explorer” and press Enter. Windows Explorer will open again. (Windows explorer is the program that you use to open My Computer or My Documents)

Taskmanager>>File>>RUN
Running a command using Task-manager File menu

How to open TaskManager

TaskManager can be opened using multiple ways.

  1. PressSHIFT+CTRL+ESC
  2. Press ALT+CTRL+DEL and click on the Start Taskmanager button
  3. Type in taskmgr into RUN(WIN+R) dialog
  4. Right click on the Task bar and selectStart Task Manager

If you didn’t already know, you can close any program or system process using Taskmanager.

Restarting Windows Explorer to apply settings

Many of the Windows System changes require you to restart Windows. This can be avoided in most of the cases just by restarting Windows Explorer. Please make sure you have Taskmanager or Command Prompt open while closing windows explorer.

  1. Open Taskmanager
  2. Goto Processes tab
  3. Select explorer.exe from the list and press End Process
  4. Wait a second until it closes
  5. Now goto File>>New task, enter explorer and press ENTER

Another technique can also be used to close Windows Explorer. Press WIN+D to show the desktop. Now bring up the shutdown dialog by pressing ALT+F4. Press ALT+SHIFT+CTRL and click Cancel.

Open Shutdown options dialog box.
Press ALT+CTRL+SHIFT and 'Cancel' in the Shutdown Dialog

any command that can be used in Run box can also be used in the command prompt and the New task option of Taskmanager. In the next post, we will be discussing the programs and commands that can be run using these techniques.

First step to a cleaner and faster Windows – understand the Registry

(Please make sure you read all the pages linked under the Links section after you finish this article)Microsoft Windows Operating Systems starting from Windows 3.1. Before the registry was introduced, each application program used “ini” files to store their configuration. This was rather messy. Windows registry was first used only to store the OS core configurations only. Later this was changed and the application program configuration were also saved in Registry.

The first step in knowing the registry is of course seeing it. Registry is ordered hierarchically and consists of six main “hives” which get their names from API definitions :

HKEY_CURRENT_USER (HKCU)
HKEY_LOCAL_MACHINE (HKLM), HKEY_USERS (HKU)
HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA
HKEY_DYN_DATA

each of these hives are further divided into sub-directories (sub-keys) in a hierarchical order. You can see these sub-keys when you click expand (+). These sub-keys contain other sub-keys and so on. This is shown in the above image.

Editing the registry

You can access registry by two methods, using RegEdit GUI tool or using “reg” command through Command Prompt. Since RegEdit method is easier, we will be discussing that method first. To open the graphical registry editor go to Start»RUN (WIN+R) , type “regedit” and press ENTER (You can find out more shortcuts in – Keyboard shortcuts for Windows). You can see the registry editor showing the two panes, one on the left showing a folder like structure (keys) and one on the right which will show the values saved in each key.

Regidtry with Hives/Keys values marked
Registry editor screen capture with Hives/Keys, Sub-keys and Values marked.

Using command prompt this process is not very straight forward. To open a command prompt, go to START»RUN (WIN+R), type cmd and press ENTER. In the command prompt type “reg /?“. ( Any command followed by /? will show a help for that particular command). You can start using command prompt for automating registry editing.

Screen capture of reg command help
reg /? will produce a small help for the command line registry editor.

Since we have two tools built-in to edit registry, we can use both of them to take a backup as well. Easier one first.

Editing the registry can be tricky. If you change some value to the wrong ones, your OS may get configured wrongly and may not necessarily be recoverable (something of a joke, but still need to warn some poor souls). Having said that it should be obvious to you that taking a backup of your registry is the best way to prevent future disasters. So we will first learn how to take a backup of the registry, even before we have learned how to edit it!

Taking a backup

Taking a backup of the registry will produce a “.reg” file, which,when opened is capable of writing the values stored in it to the registry. One thing to know is that System Restore will also create a backup of the whole registry, but this is not directly accessible.

Screen capture of opening a reg file
Opening a registration entry file prompts you to add it to the registry.

Here is the easy way. Go to registry editor “regedit” navigate tot he key you are about to edit (or not edit) and click on the KEY not not he value. You can either right click on the Key or Select File menu and then “Export”.

Screen capture of two ways to export/backup the registry
Select Export after clicking on a Key from Context or file menu.

Select the option to backup either the selected key or the whole registry. Give a name to the backup file and save. A good practice would be to give a date based name and add a bit that allows you to remember what settings you changed. You can double click on this file and restore it anytime you want. Please make sure you take a backup or a restore point before any editing.

Screen capture of options when saving a reg file
You can opt to save whether to save the whole registry or selected key

Since the easy way was fast, lets go to the slower and harder way. The command prompt command. reg command has got a command line switch which will allow you to take backup of the specified Key. the format is

reg export FULL_KEY_NAME FILE_NAME.reg

Screen capture of registry backup via reg command
Using reg command to export a registry Key - check out the crappy file name

It is pretty useless to copy each and every available command options here. Microsoft has got a really good documentation on reg command. You can read abut Registry commands and advanced techniques in the Links section. If you have any doubts or issues, post a comment and I will get back to you soon.

Good Practices

There are some easy ways to revert to a previous setting if you get screwed up changing a setting. Like when editing important files, make a copy first, name it to something like older_VALUENAME under the same Key itself and name the new Value as the original one. If anything goes wrong you can just rename the backup and save the day.

Registration entry file | Basic read on windows Registry | Recover from corrupt registry

How to shutdown, restart, logoff using command prompt?

Windows provides a builtin command to shutdown, restart as well as logoff a user from the command promptne. This and many other options are provided by the “shutdown” command. In order to find out more options of any command, type :

shutdown /? – command name followed by a forward slash and a question mark.

in Command Prompt ( WIN + R » cmd – here are some more Windows Keyboard shortcuts. You can run any command from Command Prompt or typing the command with full option into the RUN Dialog ( WIN + R ) The main use of all these commands come in batch files and task scheduling. All of these commands are pretty easy to use, please read the article completely before complaining 😉

Basic form of “shutdown”

The most basic form of the command is :

shutdown -OPTION
OR
shutdown /OPTION

Both perform the same thing – execute shutdown command with option OPTION. OPTION can take many values, only the ones of interest to us are mentioned here.

-l – Logs off the current user
-s – Shutdown the computer
-r – Restart the computer

-a – Aborts a current shutdown command execution

-t XX – if this is added with any of the above ones, you can specify after what time ( XX seconds ) the system should execute the OPTION.

A Simple example and a Screenshot

Here the OPTIONs specify that shutdown command should shutdown the command after 120 seconds.

RUNning “shutdown” command with options -s -t 120

shutdown -s -t 120

The screen result will be something like this :

Before shutdown, the logged in user is warned about the event and the time frame.

Canceling a shutdown

If you have given the time parameter -t XX you will have sometime before the command kicks you out. In that time, if you want to cancel the event just type :

shutdown -a -Abort a shutdown

shutdown Aborted – notification

Add a message

You can add a custom message with shutdown so that, instead of the time frame warning, the user will be presented with your message.

shutdown -s -t 120 -c “You are so screwed”

will present the user with the message – “You are so screwed” as below :

Custom message with “shutdown”

More about shutdown on Microsoft KB | Built in parental control in Windows XP

How to disable access to Drives using Disk Management

One of the visitors of SI, Joseph, recently asked in a comment to the post “How to disable access to specific drives with registry” how he could disable  access to a drive even for programs like Ashampoo which managed to override the registry trick. This is the trick you can use to prevent such sotware from accessing your drives. In one of the previous posts we had discussed how to Manage disk drives using Disk drive management console Object of Windows. We can use the Management Console to disable access to select drives also.

  1. Open the Disk Management Console

To open the Disk Management Console type “diskmgmt.msc” into the RUN dialog box and press ENTER.

Enter diskmgmt.msc into the RUN dialog and press ENTER
  1. Select the Drive

All the Drives in the storage devices connected to your computer will be listed here. Select the drive to which you want to prevent access and right click on it. Now select the option “Change Drive Letter and Paths..”

Right click on the drive and select "Change Drive Letter and Paths.."
  1. Remove the drive letter assignment

In the Dialog that opens, click “Remove” and then “Yes” if prompted for confirmation.

Remove the drive letter assignment.
  1. Hooray, you have disabled access to the drive

The change takes effect immediately. If it doesn’t, the try restarting windows explorer as explained.

The drive is removed from any sort of navigation..

The above mentioned trick will prevent everyone from accessing the drive for read or write purposes. Checkout the related posts for more…

How to Disable Autoplay/Autorun

As we discussed in the last post in the series, the best way to prevent infection by a Virus is to Disable Autorun. So how do you disable Autorun? The easiest way to do this is using Group Policy Editor which is a Microsoft Management Console Object. To Turn Off AutoPlay/ AutoRun follow these steps :
Watch this step by step Flash Tutorial

1. Goto START»RUN gpedit.msc

2. Browse to the folder Computer Configuration»Administrative Template»System.

 

goto Computer Configuration»Administrative Template»System


3. Scroll down and Open Turn Off Autoplay option.

4. Enable it and select All Drives

Select All Drives


This will be a system wide change. Instead if you need to turn Off Autorun just for your user account do the same in the folder –

User Configuration»Administrative Template»System

Please read the previous post in the series for some more useful tips on preventing Viruses.You might want to use the Address bar tip give at the end of last post in this series too.

What are the hidden files and folders

This is a small list of folders and files which were displayed by the method mentioned on the previous post in this series.

Hidden folders and files in C drive of Windows
Hidden folders and files in C drive of Windows

Recycler : Recycler is aanother form of Recycle Bin. The Recycler folder contains a Recycle Bin for each user that logs on to the computer, sorted by their security identifier (SID).

System Volume Information : This contains the log files and backups of important System Files that are used for System Restore in Windows. (System Restore allows you to roll back all the settings and System Files to a previous time)

MSOCache : MSOCache is the folder that contains cached Office installation files. The folder is safe to delete.

NTLDR : This is the Windows NT boot loader. This is replaced by winload and Windows Boot Manager in Windows Vista

NTDETECT.COM : This file is used by Windows NT during startup to detect basic hardware required to boot the OS. This is used for Systems having BIOS.

Autoexec.bat : is most often used to set environment variables such as keyboard, soundcard, printer, and temporary file locations. It is also used to initiate low level system utilities.
These are the main folders and files in XP.

pagefile.sys : This is the actual pagefile, as the name indicates, of Windows. This file is used as virtual memory on your system.

hiberfil.sys : As the name indicates this is the file used for Hibernation. While hibernating the system stores all the content of the RAM to this file and shuts down. The next time you start your system the RAM contents are restored from this file.

Get access to all folders in Windows like Linux

On the last article we have discussed about seeing all the files that are part of Windows. Now lets see whether we can directly access these folders. As it turns out Windows by default will not grant you permission to the folder System Volume Information.

Denied access to C:System Volume Information

Thats because the folder contains important System Restore Point informations. So what do you do when you can’t touch your own property. well it is there that the Windows file sharing comes into play. It may sound a little weird at first but it is true. Lets see how.

Step 1 : Go to Tools>>Folder Options and select View tab.

Folder options View Simple File Sharing

Here scroll down to the bottom, you can see a check box named Use Simple File Sharing (Recommended), UNCHECK the box, click APPLY and OK. Now you are done with the settings part. So just take the Properties (ALT+ENTER) or RIGHT CLICK>>PROPERTIES) of System volume Information you can see a new tab named Security here. You can see that there will be a user named SYSTEM there and it has full permission (refer picture).

System user account permission

You need to add your User account as a user here and give full permission to your self in order to gain access. Click Add button and type in your user name and click Check Names your user name will be filled along with the computer name automatically.

Add new user to security access permission

Click OK. now just click on user name of yours and check Full control. Click Apply, OK and you are done.

Allow full control

You can get access to files that return an “Access Denied” error by using this method. are some Files and Folders which need some more work to open I’ll discuss it in next post. Till then try this and figure out what all were hidden from you.

View system files (super hidden) in Explorer

This is the first among a series of posts on administering Windows . It starts with how to see the files and folders that were hidden by Windows for some reason. The series is actually inspired from the one done by Samanathon on Starting your Day with a fresh Computer. He did a good job and I am a regular visitor of Saman’s Blog.

A Super Hidden or a Protected Syetem File is a file that is normally not shown in the Windows Explorer even if you have enabled Show Hidden files (Tools>>Folder Options>>View>>Show Hidden Files and Folders) in Windows Explorer). This is because if some of these files are deleted or changed Windows may encounter a fatal error. Some of such folders are :

  • C:Windowssystem32dllcache
  • System Volume Information – this is in all the drives
  • Recycler – which is also in all the drives

Super Hidden Files in C drive

So the first step involved is to make Windows show all the Super Hidden files. This can be done in two ways. One is directly through Windows Explorer Tools>>Folder Options and the other is through registry. So the former being easier and straight forward I’ll discuss it first.

1 . Through Windows Explorer

In Windows Explorer from Tools (Alt+T) menu take “View” tab in “Folder Options”.Make sure that you have selected Show Hidden Files and Folders and that you have unchecked Hide Protected operating system files options. Click Apply and then OK. This will enable you to see system files that had previously been hidden from your view.

Showing Super Hidden Files in Tools Menu

2 . Through Registry Editing

This is a little more complex.(It is recommended that you read the following posts before you go into the registry. Try this if you know Registry editing. Make a backup of the registry before you proceed.( The Introduction to Windows Registry , Know how to backup your registry )

Follow these steps..

1 . Run ( WIN+R ) regedit and open registry editor.

Super Hidden Dword in registry

Go to the Key HKEY_CURRENT_USERSoftwareMicrosoftWindows
CurrentVersionExplorerAdvanced
.

2 . In there you will see a Registry DWORD named ShowSuperHidden Make the value 1 instead of 0.

Dword Edit

3 . Now all you need to do is to restart Windows Explorer. to do so you can goto Start>>Shut Down and Click Cancel while holding down SHIFT+CTRL+ALT. Now press ALT+CTRL+DEL this will bring Task Manager. Take File>>New Task and type explorer and press Enter.

Now if you go to any drive you can see the previously Hidden files there. Note that you will still need to enable Show Hidden files option in Folder Option.

Change the default Drive Icons in Windows XP

You can change the default drive icons available in My Computer under Windows XP through the registry. Although it is done via registry the task is pretty simple and straight forward. (You can also use the Autorun method – please read that article if you prefer to do so)

Open registry editor ( WIN+R » regedit )

Navigate to the key
HKLMSoftwareMicrosoftWindowsCurrentVersionExplorerDriveIcons

Registry allows you to change the icons associated with each drive

Here you can see some sub keys with name as drive letters in you system.

Each one of them will have another sub key DefaultIcon . The Default string under DriveIcon keyDefault string value here contains the path to the icon used for that drive. Double Click on this and set the path of the icon you want to use.

Default icons for drives in XP xhanged to Vista ones.

This will change the default icon of that drive. Repeat it for other drives also. I don’t know any easier way, but if you know just post a comment and I will publish it here and link back to your blog.

How to view all drives, Disk Management under Windows

The Disk Management object under Microsoft Management console can be used to Change Drive letter association, find unrecognized partitions or Mount a logical drive into a folder as in Linux.

If you want to prevent access to a drive, read 2nd tip in “Points to note” given after this post or read how to Prevent access to select drives using Registry.

One of the key differences between Windows and Linux is the tree structure used in Linux for filesystem. In Linux everything is a hierarchical leaf or branch of the Root “” directory. It was only recently that Linux started loading (mounting) drives other than the system drive automatically. (If you want to know more,  here is an article which will explain the Linux file hierarchy). To implement the Linux style tree structure in windows is pretty easy and is explained here.”

Open Disk Management object by typing “diskmgmt.msc” in START » RUN box or in Command Prompt. Here you can see all the Primary (Blue) and Logical (Green) partitions available on your system.

Disk Management Console object - screen shot.

You will be able to see the Linux partitions too. Select a drive and Right Click on it. Here you can see an option “Change drive Letter and Paths“. Under this option you can remove a drives letter change it or mount a volume into a folder.

Mounted Drives

Screen shot of my H and G drives mounted in a folder “C:Drives”

Some points to note here are …

1. You cannot remove the drive letter association of your system drive.
2. If you do not assign a drive letter or mount the drive to a folder on another drive it will not be accessible by any means in Windows.
3. You can’t add more than one drive letter to a drive.
4. To mount a volume the folder must be on a different partition.

Consider reading The post on Microsoft Management Console if you want to know more.