You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
@<strong>PC</strong>PRO<br />
FACEBOOK.COM/<strong>PC</strong>PRO<br />
Command<strong>Pro</strong>mpt<br />
15 doskey<br />
Create command-line shortcuts<br />
Example: doskey txt=dir *.txt<br />
In older versions of Windows, “doskey” let<br />
you use the cursor keys to browse previously<br />
entered commands. Nowadays, that<br />
capability is built into the Command <strong>Pro</strong>mpt,<br />
but doskey has another use, too: it can create<br />
macros (that is, shortcuts) for commonly<br />
used commands. The example above lets<br />
you simply type “txt” to list all the text files<br />
in the current directory. If you want your<br />
macro to run multiple commands in a row,<br />
use the $t marker to tell doskey where to<br />
“press Return”.<br />
Note that doskey macros only work<br />
within the Command <strong>Pro</strong>mpt window where<br />
they were defined. If you want your macros<br />
to work everywhere, create an AutoRun<br />
script that automatically declares them every<br />
time you open a new Command <strong>Pro</strong>mpt<br />
window (see AutoRun fun tip).<br />
16 bootrec<br />
Repair startup information when Windows<br />
won’t boot<br />
Example: bootrec /fixboot<br />
When you make a change to your <strong>PC</strong><br />
hardware, the arrangement of your hard<br />
disks may change, preventing Windows from<br />
starting up. “Bootrec” can save the day. This<br />
tool isn’t built into the standard Command<br />
<strong>Pro</strong>mpt, but it’s accessible from the recovery<br />
console, which you can access by booting<br />
from your Windows installation media.<br />
Our example above tells bootrec to write a<br />
new Windows-compatible boot sector to the<br />
primary hard disk: if that doesn’t get the OS<br />
working, try the /fixmbr switch to update<br />
the Master Boot Record, then use the /scanos<br />
and /rebuildbcd switches in turn to locate<br />
your Windows installation and make it<br />
bootable. Note that bootrec doesn’t know<br />
about dual-boot systems; additional trickery<br />
with the bcdedit command will probably be<br />
needed to regain access to a second OS.<br />
17 diskpart<br />
Create, edit and delete disks and partitions<br />
Example: select disk 0<br />
“Diskpart” is a toolbox for all sorts of<br />
low-level disk operations. To use it, type<br />
TIP: AUTORUNFUN<br />
You can set a command to be automatically executed every<br />
time you open a Command <strong>Pro</strong>mpt; this can be useful for<br />
doskey macros (see left), or perhaps you’d like to customise<br />
the interface using the prompt command. You will find<br />
instructions at pcpro.link/<strong>274</strong>autorun – the text refers to<br />
Windows 7, but the same technique works in more recent<br />
releases too.<br />
“diskpart”, then type “list disk” to see the<br />
volumes available. Use the select keyword to<br />
indicate which disk you want to work on –<br />
our example above would select the first<br />
hard disk on the system, which is usually the<br />
system disk.<br />
From here you are able to resize partitions<br />
(using the shrink and extend commands),<br />
convert MBR disks to GPT or vice versa, or<br />
completely erase a disk using the “clean”<br />
command. Using diskpart for the operations<br />
has two advantages over Windows: first, it<br />
often lets you delete volumes or partitions<br />
that appear locked in Windows; and second,<br />
you can launch it with the /s switch to pass<br />
it a script, to automate processes such as<br />
converting or partitioning disks.<br />
18 powercfg<br />
Manage power settings and monitor energy<br />
usage<br />
Example: powercfg /setactive SCHEME_<br />
BALANCED<br />
The “powercfg” command lets you manage<br />
your power options. You can see a list of<br />
power schemes by entering powercfg /l, and<br />
switch between them using the /setactive<br />
switch. Our example syntax sets the current<br />
power profile to “Balanced”, using an alias<br />
rather than a lengthy hexadecimal GUID<br />
(Globally Unique Identifier). Type “powercfg<br />
/aliases” to see a list of all available aliases.<br />
Powercfg also provides useful diagnostic<br />
information. Entering “powercfg /energy”<br />
will analyse your system and create an HTML<br />
report warning you of anything that might<br />
be draining your battery. The /sleepstudy<br />
switch will create an HTML page detailing<br />
all of the times your computer has recently<br />
been to sleep, meaning you can track down<br />
any problems. Furthermore, you can get a<br />
report on the state of your battery by using<br />
the /batteryreport switch.<br />
19 sfc<br />
Check and repair system files<br />
Example: sfc /scanfile=c:\windows\<br />
example.sys<br />
“Sfc” is Windows’ built-in System File<br />
Checker. Hopefully, you’ll never need to use<br />
the command, but if your computer gets<br />
infected by a meddling virus – or if it happens<br />
to crash in the middle of an update – then<br />
your system could end up in a semi-working<br />
state. If either scenario comes to pass, sfc<br />
checks that all your system files are working,<br />
and that they’re the correct versions: in most<br />
cases, you will want to scan your entire<br />
Windows folder, which you can do by<br />
entering “sfc /scannow”. (If you run the<br />
command with no argument you’ll just see<br />
the help text.)<br />
Scanning your whole system can be<br />
slow, however, and depending on the error<br />
messages you’re seeing, you may only want<br />
to check one particular file. You can do<br />
this using the /scanfile switch, as in our<br />
example above.<br />
TIP: PIPESANDREDIRECTS<br />
The redirect operator “>” lets you send the output of a command to a file, rather<br />
than the screen – for example, you might type “dir > dir.txt” to create a file<br />
containing a directory listing. You can also use “