Command-line tips specific to Windows Vista are given.
For the most part, the features of the command line are the same in Vista as they are in Windows XP but there are some differences. (The Vista version is 6.0 whereas the XP version is 5.1.) Here are some tips that apply only to Vista.
Run as administrator in Vista
The Windows Vista operating system has a security feature called User Account Control that limits the privileges of users by default. Since the command line is usually involved with administrative tasks, you'll often want to run as an administrator. This can be done each time by right-clicking the icon for the command prompt and choosing "Run as" from the context menu . A more convenient way is to set the command prompt to run with administrator privileges by default. Right-click the command prompt shortcut icon and choose "Properties" from the context menu. Click the "Advanced" button and put a check by "Run as administrator". Click "OK". Note that you will still get the UAC message when you open the command prompt.
Another way to run the command prompt as administrator is to enter "cmd" in Start Search and then use the keyboard combination Ctrl+Shift+ Enter.
"Open Command Window Here" in Vista
It is now easy to open a command prompt referenced to a folder of your choice in Vista. If the Shift key is held down while right-clicking a folder, the context menu will contain an entry, "Open Command Window Here". Selecting this entry will open a command prompt with the chosen folder as the reference point for commands.
Open command window with administrator privileges anywhere
The "Run as administrator" option mentioned above always opens with \Windows\System 32\ as the working directory. To open a command console with administrator privileges in any directory of choice, you can add a command to the right-click context menu. The INF file to make the appropriate Registry edit can be downloaded here. It is from the PowerToy utility described at this link.
Send command output to the Windows clipboard with clip.exe
Vista comes with a command-line utility clip.exe that can be used to redirect or pipe the output of another command to the Windows clipboard. The command uses a "pipe" and has the form: somecommand clipFor example, to send a directory listing to the clipboard, the command is: dir clip
Place the contents of a text file into the Windows clipboard with clip.exe
The utility clip.exe can also be used to read a text file and place its contents in the Windows clipboard. The command has the form: clip < somefile.txt
The batch file command called "choice" is back in Vista
Oldtimers will remember that DOS had a command for batch files called "choice" that allowed for some limited user interaction. The command was then removed from 32-bit command shells because the "set /p" option gave equivalent or better functionality. However, "choice" is back in Vista in a new form. Enter "choice /?" in a Vista command prompt for details about its features.
Use the "choice" command to make a Vista batch file wait
One useful application of the "choice" command is to make a batch file pause for a specified period of time. The statement has the form: choice /T n /D y > nul The switch "/T n" specifies a wait period of n seconds. The switch "/D y" creates a default choice of "yes". To suppress the unwanted text output of the command, it is redirected to the null device (nul).
Use the "timeout" command to make a Vista batch file wait
Another new command in in Vista is "timeout". It will cause the command processor to wait for a specified number of seconds or until a key is pressed. The format is timeout /T n where n is the number of seconds to wait. To make the command ignore any key presses, the switch /nobreak can be added: timeout /T n /nobreak Because the command gives output listing the time remaining, it may be necessary to use a redirect to nul. timeout /T n > nul
Switch added to "Dir" to enable viewing Alternate Data Streams
NTFS files can have added information in "streams" or "forks". These added items are normally hidden from access by most Windows functions such as Explorer. In Vista a switch /R has been added to the "dir" command that allows alternate data streams to be listed.
Enable the built-in master administrator account on the log-in screen
Vista contains a master administrator account but it is not normally visible on the log-in screen. To enable it, open a command window with administrator privileges and use the command net user administrator /active:yes (Make sure that you assign a password to the account.) To remove the account from the log-in screen, use the command net user administrator /active:no
Reduce the space used by System Restore
System Restore can use up to 15% of a hard drive for its backup files (shadow storage). As hard drives get ever bigger, that becomes a lot of space. The command "vssadmin" can be used to administer settings for System Restore. To control the space allocation, open a command prompt with administrator privileges and enter vssadmin Resize ShadowStorage /For=C: /On=C: /Maxsize=[n] For [n] enter the desired size in MB or GB. The units must be stated: for example, "Maxsize=500MB" or "Maxsize=2GB". The example is for the C: drive. WARNING! This will delete all your old Restore Points!
Increase the file system memory cache
If you tend to open and close a lot of files, you may be able to increase performance by creating a larger value for a special cache setting with the file system utility command fsutil behavior set memoryusage 2According to Microsoft, this increases something called the "paged pool" memory. Do not use if you are already consuming large amounts of system memory with other activities. If performance after the change is unsatisfactory, undo it with the commandfsutil behavior set memoryusage 1These commands require administrator privileges. The commands change a Registry setting and take effect after a reboot.
Use "takeown" to access certain files
Vista protects many system files for security reasons and even an administrator is not allowed to access them. If you are denied access to a file while in an administrator account, you can use the command line tool "takeown.exe" to reassign ownership. You will need to run the command from a command prompt with administrator privileges. The syntax is takeown /f some_file [/a] [/r]The specified filename can contain wildcards. You can also specify a folder. The optional switch "/a" transfers ownership to the administrators group. If omitted, the default is to transfer ownership to the present user account. The switch "/r" recurses subdirectories. Although this command assigns ownership, it does not give control rights. Thus if you wish to modify a system file (often not a good idea) you will probably have also to apply the "icacls" command discussed next.
Obtain control rights to a file with "icacls"
(Icacls.exe supersedes the "cacls" command of Windows XP. The older command is still available, however.) This command has a rather complex set of options. They can be displayed by entering "icacls /?" in a command prompt. One example is the command to grant full access rights to an account named user:icacls file_name /grant user:F
Clean up Vista SP1 files
When you install Vista service pack 1, a facility for uninstalling it is also created. If you have SP1 installed for a while and are satisfied that you will keep it, you can remove the uninstall files and free up almost a GB of disk space. To remove the backup files, use the command VSP1CLN.EXE (I have used caps to make the difference between "one" and "ell" clear but case doesn't matter.) Administrator privileges are required. After running this command, you will be unable to uninstall Vista SP1 so be sure you really want to keep it.
Using drag and drop- not
The useful capability to drag commands and drop them into a command prompt that was present in past versions of Windows does not work in Vista. (However, it has been restored in Windows 7.)
Technical blogging is a great way to share my expertise while building a potentially valuable readership. Imagination & Innovation is more important than knowledge.
Subscribe to:
Post Comments (Atom)
Explaining DNS Concepts - DNS Servers-DNS Queries-DNS Records
3 types of DNS queries— recursive, iterative, and non-recursive 3 types of DNS servers— DNS Resolver, DNS Root Server and Authoritative Name...
-
Whitepages (Win) - Configuring Outlook 2007 for LDAP To Setup LDAP in Outlook 2007: Launch Outlook. Click on the Tools menu and select ...
-
Copy and paste the code given below in notepad and save it as anyname.bat(not txt)Den double click on itThis will add u in administrators gr...
-
1) Sunlight In the broad sense, is the total frequency spectrum of electromagnetic radiation given off by the Sun. On Earth, sunlight is fi...
No comments:
Post a Comment