Tuesday, January 6, 2009

Windows from Command Line

In Linux I used command line every day. It was my filesystem explorer. It was my administration interface. It was my programs lauchpad. It was everything.

But in Windows I haven't really made use of the command line so far. Why so? Why do I spend my time clicking around the filesystem? Why do I hunt programs from Start-menu? Have I lost the spirit of command line?

I think not. Actually I really want to use the command line. But there is something really wrong with the whole command line thing in Windows.

The Default Powerless Shell

First I though that the problem is in power, that the default cmd.exe gives you so few possibilities in combining different programs together. So I installed Windows PowerShell.

PowerShell gives you a neat programming environment where you have access to the whole functionality of .NET framework. The command set is well designed and quite easy to learn with the aid of reflection capabilities it provides. It's a lot more UNIX-like than cmd.exe – it even greets you with the familiar UNIX commands like ls, rm, cp, mv, cat, ps and kill.

So the power problem was now solved, and I spent quite a bit of time playing with my new powerful toy, but I still didn't use command line for everyday tasks like I did in Linux.

Command Line Without Commands

The real problem is that in Windows you don't have any commands to run from command line.

I mean, you don't have any interesting commands to run.

Let me explain...

Of course you have commands. Powershell has a lot of built-in commands. But you can't do a whole lot with these commands alone. You really want to invoke real programs (.exe files) to do some hard work.

Again, executables are also available from command line. There are actually a whole bunch of them available. In my system I have 372 programs available from command line:

accwizfcntvdmsort
actmoviefindodbcad32spdwnwxp
AEJUninstall40findstrodbcconfspider
ahuifingeroskspnpinst
algfixmapiosuninstspoolsv
appendfltmcpackagersprestrt
arpfontviewpathpingspupdsvc
atforcedospentntspupdwxp
ati2evxxfreecellperfmonstimon
Ati2mdxxfsquirtpingsubst
atiadaxxfsutilping6svchost
atiiprxxftppowercfgsyncapp
atiphexxgdipowershellsysedit
atiprbxxgrpconvprintsyskey
atiptaxxhelpprogmansysocmgr
atmadmhhproquotasystray
attribhostnameproxycfgZyDelReg
auditusrie4uinitputtytaskman
autochkieudinitpxcpya64taskmgr
autoconviexpresspxcpyi64tcmsetup
autofmtimapipxhpinsttcpsvcs
autolfnipconfigpxinsa64telnet
blastclnipsec6pxinsi64tftp
bootokipv6qappsrvtourstart
bootvrfyipxrouteqprocesstracert
caclsirftpQuickTimeUpdateHelpertracert6
calcIsUninstqwinstatscon
charmapjavarasautoutscupgrd
chkdskjavawrasdialtsdiscon
chkntfsjavawsrasphonetskill
cidaemonjdbgmgrrcimlbytsshutdn
cisvcjviewrcptzchange
ckcnvkrnl386rdpcliptwunk_16
cleanmgrlabelrdsaddintwunk_32
cliconfglightsrdshostunins000
clipbrdlnkstubrecoveruninst_Zyxel
clipsrvlocatorredirunlodctr
clspacklodctrregunsecapp
cmdlogagentregeditupnpcont
cmdl32logmanregedt32ups
cmmon32logoffreginiuser
cmstplogonuiregsvr32userinit
complpqregwizusrmlnka
compactlprreplaceusrprbda
conimelsassresetusrshuta
controlmagnifyrexecutilman
convertmakecabrouteuwdf
cscriptmdmroutemonw32tm
csrssmemrshwbemtest
ctfmonmigpwdrsmwdfmgr
dcomcnfgmmcrsmsinkverclsid
ddesharemmcperfrsmuiverifier
debugmnmsrvcrsvpwextract
defragmobsyncrtcshareWgaTray
dfrgfatmofcomprunaswiaacmgr
dfrgntfsmountvolrundll32winchat
diantzmplay32runonceWinFXDocObj
diskpartmpnotifyrwinstawinhelp
diskperfmrinfosavedumpwinhlp32
DivXCodecVersionCheckerMRTscwinhlp32
dllhostmscdexntscardsvrwinlogon
dllhst3gmsdtcscrconswinmgmt
dmadminmsfeedssyncsdbinstwinmine
dmremotemsgserviceswinmsd
doskeymsheartssessmgrWinSCP3
dosxmshtasetdebugwinspool
dplaysvrmsiexecsethcwinver
dpnsvrmspaintsetupwjview
dpvsetupmsswchxsetupnwmiadap
drmupgdsmstinitsetverwmiapsrv
drwatsonmstscsfcwmiprvse
drwtsn32napstatshadowwowdeb
dumprepnarratorsharewowexec
dvdplaynbtstatsherlock2wpabaln
dvdupgrdnddeapirshmgratewpdshextautoplay
dwwinnetshrpubwwpnpinst
dxdiagnet1shutdownwrite
edlinnetddesigverifwscntfy
esentutlnetsetupskeyswscript
eudceditnetshslrundllvssadmin
eventvwrnetstatslrundllvssvc
exe2binnlsfuncslservwuauclt
expandnotepadsmbinstwuauclt1
explorernotepadsmlogsvcWudfHost
ExportControllernslookupsmsswupdmgr
extrac32ntkrnlpasndrec32xcopy
fastopenntoskrnlsndvol32
faxpatchntsdsol

But these aren't interesting programs. Most of them are used by Windows internally and I have no idea what for, and the ones I know about (like notepad, mspaint, explorer, ping) are of very minimal use.

Most of the programs I actually use every day aren't available from command line. Programs like Opera, Emacs, Skype and Windows Media Player.

In Linux all programs are available from command line. If you aren't on command line – you don't exist. While in Windows the command line seems to be for suckers. Real programs are available from Start-menu.

The Problem With C:\Program Files

All this is not the fault of the programs. It's the architecture of Windows that makes adding command line programs so cumbersome that you really want to avoid it if you can.

The locations for command line programs are defined by the PATH variable. In UNIX the PATH contains directories like /bin, /usr/bin, /usr/local/bin and maybe a few more. When new program is installed the executable is placed into one of these /bin-directories and through this becomes naturally available in command line.

But when a new program is installed on a Windows machine, it is placed inside a folder of its own. opera.exe goes inside C:\Program Files\Opera and firefox.exe inside C:\Program Files\Mozilla Firefox. To make a program available from command line its location needs to be added to the PATH, making it longer and longer and even longer.

I have about 80 folders under C:\Program Files. To make all these programs available from command line, I would have to add 80 new paths to the PATH variable. And the PATH is quite long already.

Imagine a PATH like this:

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Fil
es\ATI Technologies\ATI Control Panel;C:\ProgramFiles\QuickTime\QTSyst
em\;C:\Program Files\WinSCP3\;C:\Program Files\Smart Projects\IsoBuste
r;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\7-Zip;C:
\Program Files\Acro Software;C:\Program Files\Adobe;C:\Program Files\A
ltiris;C:\Program Files\AMD;C:\Program Files\ArcGIS;C:\Program Files\A
TI Technologies;C:\Program Files\AuthenTec;C:\Program Files\Avira;C:\P
rogram Files\Bentley;C:\Program Files\BitTorrent;C:\Program Files\CCle
aner;C:\Program Files\Common Files;C:\Program Files\ComPlus Applicatio
ns;C:\Program Files\CONEXANT;C:\Program Files\DIFX;C:\Program Files\Di
giDoc;C:\Program Files\DivX;C:\Program Files\DNA;C:\Program Files\Easy
Internet signup;C:\Program Files\emacs;C:\Program Files\eMule;C:\Prog
ram Files\Fingerprint Sensor;C:\Program Files\foobar2000;C:\Program Fi
les\GIMP-2.0;C:\Program Files\Google;C:\Program Files\GPLGS;C:\Program
Files\Hewlett-Packard;C:\Program Files\HPQ;C:\Program Files\Ideelabor
;C:\Program Files\Internet Explorer;C:\Program Files\Internet Explorer
Developer Toolbar;C:\Program Files\InterVideo;C:\Program Files\IT Are
ndus;C:\Program Files\Java;C:\Program Files\jEdit;C:\Program Files\Kar
en's Power Tools;C:\Program Files\KONICA MINOLTA;C:\Program Files\Logi
tech;C:\Program Files\Messenger;C:\Program Files\microsoft frontpage;C
:\Program Files\Microsoft Office;C:\Program Files\Microsoft Script Deb
ugger;C:\Program Files\Microsoft Visual Studio;C:\Program Files\Movie
Maker;C:\Program Files\Mozilla Firefox;C:\Program Files\Mozilla Thunde
rbird;C:\Program Files\Mozilla Thunderbird_new;C:\Program Files\mplaye
r;C:\Program Files\MSN;C:\Program Files\MSN Gaming Zone;C:\Program Fil
es\MSN Messenger;C:\Program Files\MSXML 4.0;C:\Program Files\MySQL;C:\
Program Files\NetDrive;C:\Program Files\NetMeeting;C:\Program Files\No
rton AntiVirus;C:\Program Files\Notepad++;C:\Program Files\Omnikey;C:\
Program Files\Online Services;C:\Program Files\Opera;C:\Program Files\
Outlook Express;C:\Program Files\pgAdmin III;C:\Program Files\Power Ar
chitect;C:\Program Files\Program Shortcuts;C:\Program Files\PuTTY;C:\P
rogram Files\Quest Software;C:\Program Files\QuickTime;C:\Program File
s\RegCure;C:\Program Files\Skype;C:\Program Files\Synaptics;C:\Program
Files\TortoiseCVS;C:\Program Files\TortoiseSVN;C:\Program Files\Visua
lSubSync;C:\Program Files\Winamp;C:\Program Files\Windows Media Connec
t;C:\Program Files\Windows Media Connect 2;C:\Program Files\Windows Me
dia Player;C:\Program Files\Windows NT;C:\Program Files\WinLemm;C:\Pro
gram Files\WinMerge;C:\Program Files\WinSCP3;C:\Program Files\xerox;C:
\Program Files\XP Codec Pack;C:\Program Files\ZTE EV-DO;C:\Program Fil
es\ZyXEL Communications Corporation

This is scary...

So I guess this finally explains why you can't make full use of Windows from command line alone.

No comments:

Post a Comment