Andrew Connell [MVP SharePoint]
1579 Posts |  42 Articles |  4864 Comments
.NET  |  MCMS  |  SharePoint  |  Office System
SharePoint Quick Links
Article Categories
Archives
Post Categories


Add to Technorati Favorites

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 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

  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 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 (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.

posted on Monday, August 21, 2006 12:00 AM

Feedback

# re: SharePoint developer tips and tricks 8/24/2006 2:59 PM AC [MVP MCMS]
Gravatar Todd- I'm not a fan of editing stuff that comes OOTB, rather I prefer to make my changes that encapsulate other things. For example, I like code gen tools to create abstract classes, and subs of concrete ones optionally so I can then tweak the concrete classes and later, keep regen'ing the abstract ones.

# re: SharePoint developer tips and tricks 8/30/2006 9:15 PM Tariq
Gravatar Hey Andrew,

Looks like your recycle script is better than my one
http://geekswithblogs.net/tariq/archive/2004/01/08/1170.aspx

# re: SharePoint developer tips and tricks 8/30/2006 10:38 PM AC [MVP MCMS]
Gravatar Tariq - Just another way to skin that damn cat :)

# re: SharePoint developer tips and tricks 8/21/2006 1:17 AM Arno Nel
Gravatar Nice tips dude :)

# re: SharePoint developer tips and tricks 8/21/2006 2:04 AM Ishai Sagi
Gravatar To recycle all application pools you can use the code from my old tip in msd2d. its a vbscript code sample that loops over the application pools and recycles them.
The code sample is at the article.

http://msd2d.com/Content/Tip_viewitem_03NoAuth.aspx?section=Sharepoint&id=55AF6881-8C1B-4269-887D-A77ABD46DF79

# re: SharePoint developer tips and tricks 8/21/2006 6:47 AM Shane Perran
Gravatar Great Tips Andrew

# 3 Tipps für SharePoint-Entwickler 8/21/2006 5:24 AM SharePoint, SharePoint and stuff
Gravatar Andrew Connell  hat drei kleine, aber feine Tipps veröffentlicht, die dem SharePoint-Entwickler...

# re: SharePoint developer tips and tricks 8/23/2006 8:52 AM Todd Bleeker
Gravatar Andrew,

My alternative to your Tip #1 and Tip #2 is to include the bin directory of the 12 Hive in the PATH variable of the VS.NET command prompt.

@rem
@rem Add WS v3 bin to PATH.
@rem
@set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH%

However, I've always edited the vsvars32.bat in C:\Program Files\Microsoft Visual Studio 8\Common7\Tools directory directly. I like the idea of creating a batch file that proceeds vcvarsall.bat. I like the idea so much I think I'll change the way I've done this for years.

<Todd />

# Adding Intellisense When Editing XML Files in WSS v3 / MOSS 2007 10/20/2006 2:11 PM Andrew Connell [MVP MCMS]
Gravatar Adding Intellisense When Editing XML Files in WSS v3 / MOSS 2007

# re: SharePoint developer tips and tricks 2/19/2007 1:35 PM kert
Gravatar There is another much faster method of unloading/reloading a sharepoint app than recycling or restarting iis.
Which includes unloading all application DLLs from memory ( which allows you to copy them over in application bin, Inetpub\wwwroot\wss\VirtualDirectories\80\_app_bin )
This is good for developing custom pages under _layouts and so on.

Create a file named unload.aspx, for example under
template\LAYOUTS
and place this code in it
try { HttpRuntime.UnloadAppDomain(); } catch {}
By requesting that page ( im doing that directly from VS.NET custom build step ) you immediately unload the app from memory. Right in the same step, i copy my page DLLs to _app_bin
For accessing the page im abusing wsdl.exe :), should use wget or something probably.






# re: SharePoint developer tips and tricks 2/19/2007 3:38 PM AC [MVP MOSS]
Gravatar Kert-
This is VERY BAD guidance you're providing... never add or manage anything in the _app_bin directory... this directory is managed by SharePoint. See this for more info: http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=248

# re: SharePoint developer tips and tricks 4/5/2007 8:59 PM Spence
Gravatar A tray applet to ease the pain (a little)

http://www.harbar.net/archive/2007/04/06/App-Pool-Recycler-for-SharePoint-devs.aspx

# re: SharePoint developer tips and tricks 4/5/2007 10:41 PM AC [MVP MOSS]
Gravatar Holy crap... nice utility Spence!!!

# re: SharePoint developer tips and tricks 10/10/2007 5:24 AM Ajay
Gravatar This is a nice tip, I have also discovered one more.
If you have are creating xml file in Visual Studio, adding schema to it gives access to intellisense...very handy

Cheers,
A

# re: SharePoint developer tips and tricks 10/10/2007 8:38 AM AC [MVP MOSS]
Gravatar Ajay-
There's an even easier way: http://andrewconnell.com/blog/archive/2006/10/20/4944.aspx

# re: SharePoint developer tips and tricks 5/4/2008 6:53 AM Daniel Losch
Gravatar I create a file system reparse point - something like a link in Unix filesystems - using the (most excellent) junction tool from sysinternals (http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx)

junction.exe c:\wss “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\”

That gives me something like c:\wss pointing to the 12 hive and stsadm.exe under c:\wss\bin.



# re: SharePoint developer tips and tricks 5/4/2008 10:23 AM AC [MVP MOSS]
Gravatar Daniel-
Great tip! I didn't know what is what the junction util did!

# re: SharePoint developer tips and tricks 5/16/2008 2:51 PM Peter Brunone
Gravatar Thanks for the tips, Andrew!

Oh, and I didn't know SharePoint could also host evil spirits.



# re: SharePoint developer tips and tricks 7/4/2008 10:15 AM kathy
Gravatar I used the warm up script in my company's lab server. The sharepoint 2007 website needs user to provide credential to login. I tried several times and did not find any different. It is still very slow to login after iisreset. I looked at the script, it is only hit the site without user name and password. Does the script work for the site with username and password? Andrew, any tips on this? Thanks in advance

# re: SharePoint developer tips and tricks 7/4/2008 10:38 AM AC [MVP MOSS]
Gravatar Kathy-
The script will run under the context of the user who's running the script, and those credentials will be used on the site. Make sure you set up the script to run under an account that has permissions to the site.

# re: SharePoint developer tips and tricks 8/5/2008 5:23 PM Aaron Wiggans
Gravatar Here is one tip that may save someone a few minutes of time. Our site is SSL enabled. When running the base script, it was not working. Upon further examination of the WarmUpServer file, we need to change the code in the HitPage section to use https vs. http.

:HitPage
echo Hitting https://%1%2 ...
cscript HttpRequest.vbs GET https://%1%2 /q //nologo


# re: SharePoint developer tips and tricks 1/9/2009 5:25 AM Jignesh
Gravatar Hi All.. I am in search of "The ability to move or copy files between folders within a particular library, or between two different libraries using drag and drop* " in WSS.. In short i want to develop the feature so that I can drag one document form within one folde and can drop it into another folder in the document library in the same site or different site. Please for god shake help me Any further assistace will be apprciated.. Can anybody help me... How can i do this programmatically.. Thanks in advance.. Bye Jignesh Patel+91-9879912325

# re: SharePoint developer tips and tricks 1/9/2009 7:51 AM AC [MVP MOSS]
Gravatar Jignesh-
Look at the Windows Explorer view... free and OOTB.

# re: SharePoint developer tips and tricks 9/5/2009 8:59 AM Jayesh
Gravatar Hi Andrew,
reset iis application pool vbs not working in windows server 2008 R2

is there any other option for that


Thanks & Regards,
-Jay

# re: SharePoint developer tips and tricks 9/5/2009 9:32 AM AC [MVP MOSS]
Gravatar Jayesh-
IIS7 does not use VBScript admin tools... they have a whole new setup (not just Win2k8 R2, but non-R2 as well... it's an IIS7 thing). You should use search... amazing how well it works:
www.bing.com/search

Specifically, this is what you want:
technet.microsoft.com/en-us/library/cc770764(WS.10).aspx

# re: SharePoint developer tips and tricks 3/23/2010 8:11 AM BinaryJam
Gravatar Extra bit for the recylce app pools.

Put your recycycle in a .CMD file.
Drap a shortcut to that .CMD file, stick it out the way on the desktop.

Edit that short cut, edit the Shortcutkey I use "Ctrl-Alt-."

Then you just hit that key combo and recycle .

V handy.



# re: SharePoint developer tips and tricks 4/20/2010 3:04 PM oyun
Gravatar This is a nice tip, I have also discovered one more.
If you have are creating xml file in Visual Studio, adding schema to it gives access to intellisense...very handy

Post Feedback

Title:
Name:
Email:
(email will not be displayed)
Url:
Comments: 
Please add 3 and 2 and type the answer here:    
All Comments Are Filtered & Moderated
Unfortunately comment spammers are just too effecient and are constantly dirtying up blogs with irrelevant and unwanted comments trying to improve their standing on search engines. All comments on this blog are moderated. I do not censor comments, but I don't approve comments with vulger language or those soliciting products. Most of the time comments are approved within a few hours of being submitted with the only exception when I'm traveling.

Why are you asking for my email address?
The only reason I'm asking for your email address, which isn't required to submit a comment, is to provide a gravatar if you've created an account for yourself and associated your email address with a small image. If you have a gravatar created for the email address you submit, it will appear next to your comment. Otherwise nothing will appear.

What is a gravatar?
A gravatar is a "globally recognized avatar." You can get more information about gravatars, as well as create your own for free, at www.gravatar.com. You can also view my gravatar here.


Copyright © 2003 - 2010 Andrew Connell
Creative Commons License 
This work is licensed under a Creative Commons License
Site design by Heather Solomon.

 
 
MOSS WCM Training
Looking for MOSS 2007 WCM developer training? Look no further! I teach my 5-day hands-on and online WCM classes for developers I offer through my company: Critical Path Training.

Get more information on the WCM courses!