Microsoft MVP Logo

Last week Joel Oleson blogged about the warm-up scripts you'll find on the MOSS 2007 Beta 2 Tech Resource DVD. These scripts essentially force a JIT compilation of all pages in a SharePoint site and run STSADM.EXE to warm up the admin interfaces. These are invaluable, especially to people doing presentations or demons on SharePoint. I immediately modified them for my standard SharePoint virtual machine and made sure they run on startup, as well as added a shortcut to the Quick Launch toolbar so I can quickly fire them off when I switch from slides to demo. For more info on the scripts, check out Joel's post:

» Warm Up your SharePoint Servers...

In addition to these scripts, I thought I'd post three other "tricks" I like to add to all my SharePoint virtual machines. All of the following tricks are things that will help SharePoint developers. Hopefully you'll get as much use out of these as I do!Note: all tips are written for WSS v3 (and MOSS 2007)... they will work for WSS v2 (and SPS 2003), but you'll need to modify them a bit.

Tip #1: Add Command Line Shortcut to "12 Hive"I'm not talking about creating a shortcut to the 12 Hive (the directory where just about everything WSS v3 is installed) on your desktop/Quick Launch. Like most people, I create a "12" toolbar on my Start Menu (as shown in the image to the right)... not talking about that either.

When you're in a command prompt, sometimes you need to navigate to the 12 Hive directory. But no one wants to type the directory path to c:\Program Files\Common Files\Microsoft Shared\web server extensions\12. Wouldn't it be easier if you could just type the following to get there?

c:\>cd\c:\>cd %12hive%c:\Program Files\Common Files\Microsoft Shared\web server extensions\12

I'd sure say it is! The other thing is I almost always want to be within a Visual Studio Command Prompt to have easy access to things like SN.EXE and GACUTIL.EXE. A VS Command Prompt is nothing more than a simple batch file. I've created my own batch file that executes the VS Command Prompt batch file and sets the %12HIVE% variable to the 12 Hive directory. Here's how:

  1. Create a new file called SharePointCommandPrompt.cmd and insert the following text in it (if you're on a 64 bit system, you'll want to make the appropriate changes):

    @echo offecho Setting 12HIVE environment variable.set 12HIVE="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86

  2. After saving the file, create a new shortcut with the following target:

    %comspec% /k ""c:\[Path To The File You Just Created]\SharePointCommandPrompt.cmd""

  3. To put a cherry on top, drag the shortcut onto your Quick Launch toolbar... should work like a champ!

To try it out, click the shortcut and type CD %12HIVE% at the command prompt. You should change directories to the root of the 12 Hive.

12HiveCommandPrompt

Tip #2: Access STSADM.EXE From any Directory in a Command PromptSTSADM.EXE, the main administration utility for SharePoint, is still just a command line utility. You'll find it in %12HIVE%\BIN. To run it, you have to actually be in that directory... an inconvenience to me! Instead, add the directory to the PATH environment variable so you can type STSADM.EXE from any directory on your system. To do this:

  1. Start -> All Programs -> Control Panel -> System
  2. On the Advanced tab, click the Environment Variables button.
  3. Select the variable Path and click the Edit button.
  4. Add the following to the end of the Variable value field (don't forget the semicolon... the Path environment variable is a semicolon delimited string of directories):;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
  5. OK out of all the dialogs.

Next time your system restarts, you'll be able to type STSADM.EXE at a command prompt from any directory on your system.

Tip #3: Recycle Application Pools, not IIS (I got this tip from my colleague Todd Bleeker)So many things in SharePoint require you to recycle the the W3WP.EXE process running SharePoint in order for certain changes to be picked up. So many people think this means recycling IIS by typing IISRESET. But it takes so long for IIS to recycle!

Did you know you don't have to recycle IIS most of the time, just the application pool your site is running within? Yup! For development purposes, I run all my SharePoint sites off the same app pool. I know, not the most secure, but each app pool consumes roughly 100MB of memory so why have a ton of them floating around in a virtual machine when memory is precious!

Instead of recycling IIS, I create a shortcut that I add to my Quick Launch that recycles the app pool all my sites run under. To do this, create a new shortcut on your desktop and enter the following target:%windir%\system32\cscript.exe c:\windows\system32\iisapp.vbs /a "[Name of your App Pool]" /r

Then drag the shortcut onto your Quick Launch toolbar. Click it and watch how fast an app pool is recycled compared to IIS!

[Update 8/21 1:30p] Fixed a few typos.[Update 8/29 11:00a] I've received a few questions about what changes I did to the scripts. My changes were strictly for my development environment, but they should give you an idea of what you can change: The only changes I made are to the [startup.bat] and [warmupserver.cmd] files. In the default [startup.bat] file, you'll see the last line calls the [warmupserver.cmd] file with the parameter of 'moss.litware.com'. I replaced 'moss.litware.com' with the name of my site, and added another duplicate line for each site I have installed (so, first I call it against the Central Admin, then each site I've created in succession). As for the [warmupserver.cmd] file, I removed the second and third "call :HitPage moss:*" lines (as I already took care of the central admin from the [startup.bat] file... and on my machine I'm not playing with SSP's yet.

Comments powered by Disqus