Scott Hanselman

A better PROMPT for CMD.EXE or Cool Prompt Environment Variables and a nice transparent multi-prompt

July 14, 2006 Comment on this post [10] Posted in PowerShell | ASP.NET | XML | Tools
Sponsored By

A number a people have commented on my simple, but customized command prompt. Actually I have a few, but for cmd.exe, I do this. Right-click on My Computer|Properties. Then from the Advanced Tab, click Environment Variables, then add a new User Variable called PROMPT and set it to $p$_$+$g. This came originally from Craig Andera, who got it from Shawn Van Ness. Sahil Malik also has some great command line tricks. Junfeng points out the little known ntcmds.chm.

A screenshot of the System Properties Dialogs

Here's the breakdown:

  • $P = Current Directory's Path
  • $_ = Carriage Return
  • $+ = A plus sign for each level in the PUSHD/POPD stack.

Here's some other interesting prompts. Paste these into any CMD.EXE window:

set prompt=[%computername%] $d$s$t$_$p$_$_$+$g

yields this. Note the use of an environment variables within a prompt. Here's an extensive list of environment variables.

[SCOTTPC] Thu 07/13/2006 22:19:20.40
C:\Documents and Settings\Scott

Another nice one:

set=prompt=$m$_$p$g

yields this when on a UNC Mapped Drive:

\\FREDPC\C$
Z:\Documents and Settings\Fred

There's all sorts of crap that PROMPT /? gives you:

  $A   & (Ampersand)
  $B   | (pipe)
  $C   ( (Left parenthesis)
  $D   Current date
  $E   Escape code (ASCII code 27)
  $F   ) (Right parenthesis)
  $G   > (greater-than sign)
  $H   Backspace (erases previous character)
  $L   < (less-than sign)
  $N   Current drive
  $P   Current drive and path
  $Q   = (equal sign)
  $S     (space)
  $T   Current time
  $V   Windows XP version number
  $_   Carriage return and linefeed
  $$   $ (dollar sign)
  $+   zero or more plus sign (+) characters depending upon the
       depth of the PUSHD directory stack, one character for each
       level pushed.
  $M   Displays the remote name associated with the current drive
       letter or the empty string if current drive is not a network
       drive.

Here's my command prompt. It's transparent because I use the awesome Console 2.00 Beta, build 122 hosted at SourceForge. I blogged about this last November.

Note the multiple tabs. I've got PowerShell, CMD.EXE and two VisualStudio Windows, each in their own tab. I could add a tab for Cygwin, but really, with PowerShell, who needs ls -alogF?

Scottconsole1

Console uses a XML settings file (console.xml) that takes a while to understand. Here's a snippet of my settings. I used short filenames in the VS.NET stuff for simplicity and avoidance of quoted quotes. Remember, DIR /X will give you short filenames for things like this.

...Snip...this is a PARTIAL snippet for illustrative purposes...

<tabs>
  <tab title="Console">
   <console shell="" init_dir=""/>
  </tab>
  <tab title="PowerShell">
   <console shell="c:\program files\windows powershell\v1.0\powershell.exe" init_dir=""/>
  </tab>
  <tab title="VS.NET 2003">
   <console shell="cmd /k C:\PROGRA~1\MICROS~2.NET\Common7\Tools\vsvars32.bat" init_dir=""/>
  </tab>
  <tab title="VS.NET 2005">
   <console shell="cmd /k C:\PROGRA~1\MID05A~1\VC\vcvarsall.bat" init_dir=""/>
  </tab>
 </tabs>

My font is Consolas, Size 15, Kermit Green (0x00FF00). Enjoy.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

The procedure entry point GetProcessImageFileNameW could not be located in the dynamic link library PSAPI.DLL (after IE7)

July 14, 2006 Comment on this post [0] Posted in Bugs
Sponsored By
If you enjoyed this post, or this blog, please make a secure tax-deductable donation to the American Diabetes Association. Please read my personal story about life as a diabetic and donate today.

If you start getting this stunning error on startup, you likely:

  • Just installed IE7 Beta2 or Beta3
  • Also have installed one of:
    • Verizon DSL schmutz
    • Ergodex Manager for the DX1 Pad
    • SmartBridge (MotiveSB.exe)
    • Something else that is distributing an old version of PSAPI.dll

Psapi

The solution is to search your hard drive for all instances of PSAPI.dll and rename them to something like PSAPI.old.

UPDATE: I've received one report where someone had trouble with this tip, and he suggested leaving the PSAPI.dll in c:\windows\system32 alone. I didn't, but you should be aware and possibly try first with that one DLL left alone.

This problem was debugged using ProcessExplorer to ask folks (other processes) WHERE their PSAPI came from...

Psapiprocexp

Crisis averted, at least for me.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Hanselminutes Podcast 24 - More Advanced PowerShell

July 13, 2006 Comment on this post [1] Posted in Podcast | PowerShell | ASP.NET | XML | Tools
Sponsored By

HanselminutesMy twenty-fourth Podcast is up. This episode is about some more advanced aspects of Windows PowerShell and could be called PowerShell/Monad Part 2. For Part 1 take a look at the first Podcast on Monad (PowerShell's previous name) here.

Jeffrey Snover, PowerShell Architect has already reviewed this week's show and testifies to it not sucking. Cool!

We're listed in the iTunes Podcast Directory, so I encourage you to subscribe with a single click (two in Firefox) with the button below. For those of you on slower connections there are lo-fi and torrent-based versions as well.

Subscribe to my Podcast in iTunes

NEW COUPON CODE EXCLUSIVELY FOR HANSELMINUTES LISTENERS: The folks at XCeed are giving Hanselminutes listeners that is Coupon Code "hm-20-20." It'll work on their online shop or over the phone. This is an amazing deal, and I encourage you to check our their stuff. The coupon is good for 20% off any component or suite, with or without subscription, for 1 developer all the way up to a site license.

Our sponsors are XCeed, CodeSmith Tools, PeterBlum and the .NET Dev Journal. There's a $100 off CodeSmith coupon for Hanselminutes listeners - it's coupon code HM100. Spread the word, now's the time to buy.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

  • The basic MP3 feed is here, and the iPod friendly one is here. There's a number of other ways you can get it (streaming, straight download, etc) that are all up on the site just below the fold. I use iTunes, myself, to listen to most podcasts, but I also use FeedDemon and it's built in support.
  • Note that for now, because of bandwidth constraints, the feeds always have just the current show. If you want to get an old show (and because many Podcasting Clients aren't smart enough to not download the file more than once) you can always find them at http://www.hanselminutes.com.
  • I have, and will, also include the enclosures to this feed you're reading, so if you're already subscribed to ComputerZen and you're not interested in cluttering your life with another feed, you have the choice to get the 'cast as well.
  • If there's a topic you'd like to hear, perhaps one that is better spoken than presented on a blog, or a great tool you can't live without, contact me and I'll get it in the queue!

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

FLV won't play when a Camtasia Video is uploaded to an IIS site

July 13, 2006 Comment on this post [2] Posted in Musings
Sponsored By

FlvmimetypeI put a one hour Camtasia video up for a customer today and it wasn't loading. It would show all the signs it was working with the controls and what-not showing up, but the flash video itself (the FLV) wasn't loading.

I checked the IIS logs (always check the logs!) and saw a 404 when index.flv was requested. I knew the file was there, but the request ended in a 404. I also checked the UrlScan logs to see if we weren't applying a whitelist. We weren't.

Turned out that there was no mime-type applied for the FLV extension. Added it, and poof, worked. Ah, life's little details.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Scott Hanselman: Developer Productivity Tools Video Part 1

July 12, 2006 Comment on this post [7] Posted in TechEd | PowerShell | XmlSerializer | Speaking | Web Services | Tools
Sponsored By

Wroxvideo1When I was at TechEd I visited the Beantown.net INETA User Group and gave a (fairly ad-hoc) talk on Developer Productivity Tools. Jim Minatel loaned me his microphone and a copy of Camtasia and we recorded the talk. Thanks Jim!

It was a great crowd, a lot of fun. We had a number of "off the cuff" discussions about random stuff so I hope it doesn't take away from the gist of the talk.

The complete presentation was around 1 hour 45 minutes, so for online, Jim has split it into 4 segments. This week's segment is available now and is about 33 minutes long. If you watch it in your browser, I recommend you double click on Windows Media Player to make the video go full screen.

It covers:

  • 00:00 Title
  • 00:15 Scott's introduction
  • 00:40 The first tool: Notepad 2
  • 02:40 Little-known built-in command line tools
  • 09:55 Process Explorer and Slick Run
  • 15:15 ILDASM
  • 16:15 .NET Reflector
  • 24:45 NGEN

The remaining three segments for following weeks will cover roughly:

  • Week 2: XmlSerializer - 20 minutes
  • Week 3: Windows PowerShell - 33 minutes
  • Week 4: Active Words, Code Rush, SOAP Scope, XML doc viewer - 23 minutes

There's also some other good screencasts up at Wrox. The growing list of videos is available at wrox.com. The first few videos in the series are:

I hope you enjoy them.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.