Oops I'm A Geek

Monday, November 30, 2009

Add STSADM to your system path

Anyone who does anything with SharePoint knows that the Stsadm.exe command is indispensible. It’s used for so many administrative, troubleshooting, and maintenance tasks. Problem is, it’s buried way deep down inside the Program Files directory, and you need to dig down to that location before you can start using the command. Here’s a great tip for making Stsadm easier to get to and easier to use.
1. Open Notepad and enter the following commands. Each bullet represents one line in the text file:
• @echo off
• set path=%path%;c:\program files\common files\microsoft shared\web server extensions\12\bin
• d c:\
• @echo on
2. Save the file as “STSADM Command Prompt.bat” in a location accessible to both your normal user account and your administrative user account (if they are different). The batch file can be hidden away somewhere--but it's important that you have permission to read the file as both your normal user account and your administrative account.

3. Create a shortcut to the batch file. Put the shortcut somewhere very accessible, like on your desktop or in your Start menu.

4. Open the properties of the shortcut. On the TARGET line, add to the beginning of the line: cmd.exe /k
5. Click the Apply button. Windows will change cmd.exe /k to c:\windows\system32\cmd.exe /k.
• The Target line will now read:
C:\WINDOWS\system32\cmd.exe /k "path\STSADM Command Prompt.bat"
6. Click the Advanced button.
7. On Windows Vista or Windows Server 2008, select Run As Administrator. On Windows XP or Windows Server 2003, choose Run With Different Credentials (assuming you use a separate, administrative account to run Stsadm).
Double-click the shortcut. You’ll be prompted to run the shortcut with appropriate administrative credentials. Then a command prompt will open, set to the root of the C:\ drive (based on the third line in the batch file). Type path and press Enter. You’ll see that the system path now includes the folder in which Stsadm is found. That folder was added to the system path by the second line in the batch file.
Test the command prompt by typing STSADM /? and pressing Enter. You’ll see the usage information for Stsadm.exe displayed. Now you can use Stsadm commands to administer the server without having to dig into the deepest crevices of the Program Files folder.
OR

Add path to environment variables
Control Panel>Under System Properties, Advanced tab, Environment Variables button.
Select the "Path" system variable. Add your path to the SPRoot\BIN folder. Now all (future) command prompts have access to STSADM (and anything else in BIN folder).

0 Comments:

Post a Comment

<< Home