Pages

Monday 28 February 2011

SharePoint 2007 Tips and Tricks

My First blog:
What better way to start of by posting a few SharePoint 2007 (MOSS) tips and tricks.

--> -->
Tip #1: Add Command Line Shortcut to "12 Hive"
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
The other thing is you 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.
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 off
echo 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
  1. After saving the file, create a new shortcut with the following target:
%comspec% /k ""c:\[Path To The File You Just Created]\SharePointCommandPrompt.cmd""
  1. 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.
Tip #2: Access STSADM.EXE From any Directory in a Command Prompt
STSADM.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
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? For development purposes, run all SharePoint sites off the same app pool. Though, 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
Click the shortcut and watch how fast an app pool is recycled compared to IIS!