If you run Windows, you should head over to Windows Update immediately. The WMF vulnerability has been patched ahead of schedule.
Archive for the 'Windows' CategoryPage 3 of 3
Unix-heads are used to perl scripts begining with #!/usr/bin/perl (the so-called, “shebang” notation). This is a feature I’ve always missed on Windows.
Thanks to Google’s filetype keyword, I found I a solution.
@rem = '
@echo off
\path\to\perl\perl.exe %0.cmd %*
exit /B %ERRORLEVEL%
';
print "Hello Perl World!";
The one caveat here is that you must name your file with the .cmd extension.
Update: Changed to return a proper errorlevel. Thanks, Kevin.
Turns out that Microsoft’s doskey command can actually create aliases that work in a command prompt (cmd.exe). Microsoft calls these things “macros”. Here’s my current list:
C:\>doskey /macros
measure=start /B /WAIT /HIGH /AFFINITY 1 ntimer.exe $*
sad=jvf -r -mmaster.amd64 -ddiffs.amd64
view=vim -R $*
vimrc=vim %ESSENTIALS%\vim\_vimrc
spec=cd G:\cpu2000
p2=nenscript -2GNr -TUS $*
p1=nenscript -GNr -TUS $*
svn=svn --config-dir %ESSENTIALS%\subversion\config $*
vsdbg=devenv /debugexe $*
cmd=start %ComSpec% /K %ESSENTIALS%\setenv.cmd
vc32=vc80env.cmd x86
vc64=vc80env.cmd amd64
ss=sd sync * && for /D %D in (*.*) do start sd sync %D\...
ap=PATH=%PATH%;%CD%
wl=less -S -# 2 $*
dis=link /dump /disasm $1 | less -S -#3
which=where $*
vf=jvf $*
vi=vim $*
ll=ls -l $*
One of my personal favorites is “ap”, which adds the current directory to your path.
Update: Kevin found a bad-ass application for this.
I just upgraded to iTunes 4.8 and noticed that the CD ripping stuff finally works on Windows x64. This is good news.
Here are some CMD tools you probably didn’t think existed:
findstr- Like Unixgreptasklist- Like Unixpstaskkill- Like Unixkill
These come for free with recent versions of Windows. You might be wondering why Microsoft chose these names instead of their well-known, pre-existing Unix equivalents? I don’t know for sure, but I suspect this has something to do with it.
Anyway, here’s a nice trick:
C:\>tasklist /m msvcrt.dll
Image Name PID Modules
========================= ======== ===============
OUTLOOK.EXE 3576 MSVCRT.dll
cmd.exe 2616 msvcrt.dll
vim.exe 3816 msvcrt.dll
iTunes.exe 3776 msvcrt.dll
firefox.exe 2912 msvcrt.dll
Whip that one out next time you can’t delete a directory because some DLL is in-use.
When manipulating files and directories, there are some actions that are naturally easier from the command line, and others that are easier from Explorer. For example, you might navigate to a directory using Explorer and then delete every file named foo*.txt using the CMD prompt.
I’m a big fan of the Command Window Here PowerToy as a means to get from Explorer to a CMD prompt.
But what about the opposite situation? Lets say I’ve just run a command line program and redirected the output to a file. Now I decide to attach the file in a new email message. Ideally, I’d drag-and-drop the file into the message, but I can’t because I’ve only got a CMD window.
For years, I’ve lusted after a solution to this annoyance, and it turns out that there is one. It’s amazingly trivial:
start .
Yup, that’s right: start dot. It’s obvious if you understand what the start command does, but I’ll be the first to admit I never would have though of this myself.
One perk of working in Redmond is the opportunity to steal some Windows-mojo from the folks who create it.
Update 3/28/2008:
Just discovered that the Mac OS X equivalent is:
open .
Yes that’s right: open dot. I dig the symmetry.
If you violate the “principle of least surprise” you should be prepared to face the wrath of your users. Here’s today’s example:
The Windows start command does about a million things. One of them is to launch a new process. If you are benchmarking, it can be useful to launch the benchmarked process this way so that you can influence it’s scheduling priority, processor affinity, etc.
The command supports the following two switches, among others:
- /B - Start application without creating a new window.
- /WAIT - Start application and wait for it to terminate.
The usage summary includes this output:
START
["title"][/D path][/I][/MIN][/MAX][/SEPARATE|/SHARED]
[/LOW|/NORMAL|/HIGH|/REALTIME|/ABOVENORMAL|/BELOWNORMAL]
[/AFFINITY
[parameters]
Notice the order of the /WAIT and /B switches. Guess what? If you issue the switches in this order, the /B switch silently cancels the effect of the /WAIT switch. You need to use the switches in the other order if you want them to work properly. As far as I can tell, these are the only two order-dependent options to start.
Believe it or not, this is the intended and completely undocumented behavior.
Funny, but knowing that this was done on purpose in no way gives me the last hour of my life back.

Latest Comments
RSS