Thursday, April 15, 2010

When it's the best you've got...

I use mostly Linux and Mac, but I'm frequently forced to use Windows at client sites.  The Windows cmd.exe is pretty lame, but here are some tips to do a few useful things.


start /b  - run something asynchronously

findstr  - poor man's grep

dir /S   - recursive directory list

dir /S *.java  - can do it with file name patterns

dir /S | findstr

dir /b  - bare names

dir /b /S [pattern] | cmd     -- this will open all the files that match the pattern (as long as an editor is registered for the extension)

fc -- not as good as diff, but can get you something when you've got nothing

systeminfo

systeminfo | findstr Time:
(if you shut down your laptop every night when you go home, this shows you how long you've been on the clock)

driverquery

%ERRORLEVEL% - returns the error code of the most recently used command.

%HOMEPATH%  - best we can do without ~/

set  - shows environment variables,  'set p' shows only variables starting with 'p' etc.,  set aslo sets variables.

%RANDOM% - returns random int between 0 and 32767
(for when you need to make a decision. nice coin toss)

reg  - display and work with registry entries, might have to combine with runas

pushd/popd  - push/pop directories for quick in and out

sort  - sort files or pipe standard output to it

tasklist  - same list as taskmanager, but on the command line, useful with...

taskkill - to kill one of those frequently misbehaving windows processes

sc  - control and interact with services

No comments:

Post a Comment