Restart Services from the command line

Wednesday, October 31, 2007
Here's a handy batch file I wrote that stops and starts a service on the local or remote computer from the command line. You must have administrator rights on the target computer for the batch file to run properly.

@echo off
if "%1" == "" Goto Syntax
if "%1" == "?" Goto Syntax
if "%1" == "/?" Goto Syntax
if "%2" == "" Goto RunLocal

echo %1 Find "\\" > nul
If %errorlevel% == 1 Goto Syntax
sc %1 query %2 Find "."
If %errorlevel% == 0 Goto End
sc %1 qc %2 Find "DISABLED" > nul
If %errorlevel% == 0 echo The requested restart is not valid for this service. & Goto End

echo The %2 service is stopping...
sc %1 stop %2 > nul find "started" > nul
If %errorlevel% == 0 Goto Loop
echo The %2 service was stopped successfully.
echo The %2 service is starting...

sc %1 start %2 find "running" > nul
If %errorlevel% == 0 Goto StartLoop
echo The %2 service was started successfully.
Goto End

net stop %1 & net start %1
Goto End

echo Stops and starts a service on the local or remote computer.
echo Syntax: RESTART [\\Computer] ServiceName

Copy the text above into Notepad and save it in your Windows folder as "Restart.bat".
Read more ...

Using DiskPart

Thursday, October 18, 2007
This post is mainly for me, since I never can seem to remember the commands to use. :)

DiskPart is a utility that, among other things, allows you to specify the cylinder alignment of hard drives. Exchange and SQL particularly benefit from a 64KB sectors. So much so, in fact, that 64KB alignment is (finally!) the default in Windows Server 2008.

There are plenty of resources on the net that explain when and how to use it. A good explanation by the Exchange Blog can be read here and the Microsoft reference for DiskPart is here.

The commands I use are:
Microsoft DiskPart
version 5.2.3790.1830
Copyright (C) 1999-2001 Microsoft Corporation.
On computer: Exchange2003

DISKPART> select disk 1

Disk 1 is now the selected disk.

DISKPART> create partition primary align=64
DiskPart succeeded in creating the specified partition.

Then open Disk Management, assign a drive letter to the new drive and format it as usual.
Read more ...

Fixing Side-By-Side Errors

Friday, October 12, 2007

I've run across a few servers that are throwing the following "Side By Side" error in the Application event log:

Event Type: ErrorEvent
Source: SideBySide
Event Category: None
Event ID: 59
Date: 10/12/2007
Time: 7:30:55AM
User: N/A
Computer: FDOMOPS01
Description:Generate Activation Context failed for C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFC_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_DEC6DDD2\MFC80U.DLL. Reference error message: The referenced assembly is not installed on your system.

Usually, I've found these servers to be running SQL 2005. The fix is to install the Microsoft Visual C++ 2005 Redistributable Package. It's available here:

Read more ...

Using Windows Mobile AutoCorrect to Automatically Replace Text

Saturday, October 6, 2007
I love my Windows Mobile device, an AT&T 8525 (also known as the HTC Hermes). But as a former Blackberry user I really miss the Blackberry's AutoText feature.

AutoText allows you to enter a text string that will be replaced by another text string.

For example, if I'm driving and someone sends an email I need to reply to, I can reply with "cm" (call me) and the device would automatically change it to "Please call me on my cell at (650)555-1212."

This article explains how to achieve the same functionality on a Windows Mobile device using Windows Mobile's AutoCorrect feature.

First, ensure that you are able to view hidden files and folder in Windows Explorer. This is done on the Tools Folder Options View tab of Windows Explorer. If you have Windows XP, you will also need Microsoft ActiveSync 4.2 or better installed and configured on your computer. ActiveSync can be downloaded here. If you have Windows Vista, download and configure Windows Mobile Device Center 6.1 for Windows Vista here.

  1. Create an ActiveSync connection
  2. Click Explore in ActiveSync
  3. Navigate to your mobile device's \Windows folder
  4. Locate the autocorrect.txt file and copy it to the Desktop. Note: Your autocorrect.txt file may be named differently. Mine is named autocorrect.0409.txt
  5. Rename the autocorrect.txt file on your mobile device as a backup in case you need to restore it later
  6. Right-click the autocorrect.txt file on your Desktop and select Properties. Clear the Read-only checkbox and click OK. Note: If you don't see the autocorrect.txt file on your Desktop, it's because you aren't able to see hidden files.
  7. Open autocorrect.txt in Microsoft Excel
  8. Insert as many rows as necessary and enter your new AutoCorrect entries. Column A is the text you want to correct and column B is the corrected text. For example,
    jeff for column A and Jeff for column B. See the example below.
  9. Use Excel's data sorting feature to alphabetize the text by column A. Windows Mobile will not read the file correctly if it is not in alphabetical order.
  10. Save the autocorrect.txt file in its current format
  11. Drag and drop the autocorrect.txt file from the Desktop to the \Windows folder on the Windows Mobile device
  12. Reset the Windows Mobile device to begin using the new AutoCorrect entries. Windows Mobile reads the autocorrect.txt file at start up.

Note: Be careful not to enter a text string to replace that you might actually use. For example, if you configure "im" to be replaced by "I'm", the phrase "My IM address is" will be converted to "My I'm address is".

Read more ...

Installing Exchange 2007 SP1: Notes from the field

Wednesday, October 3, 2007

NOTE: These upgrade notes are for Exchange SP1 Beta 2. Many readers have found this useful in their RTM upgrades. Also please see my latest post that discusses the installation of SP1 RTM. - Jeff

The following are my notes for installing Exchange Server 2007 Service Pack 1 Beta 2. As with most beta software, upgrades may not go as smoothly as they will in the final product. I came across some problems and solutions, which I'll share with you and will hopefully make your upgrade smoother.

I'm not going into a lot of detail on each of these steps, so if you want more info please post your question and I'll do my best to answer.

My setup is a single x64 dual-core host with 4GB RAM. It functions as my Microsoft Exchange 2007 Edge server and runs VMware Workstation 6.01. It runs two VMs, one Windows Server 2003 SP2 x64 Domain Controller and one Exchange 2007 x64 Hub Transport, CAS, Mailbox server running E2K7 Update 4. The Edge server is running Microsoft Forefront Security for Exchange RTM.

The Exchange 2007 SP1 release notes say to update your Edge, Hub Transport and CAS servers before your mailbox servers. It also says that Forefront Security for Exchange RTM is incompatible with Exchange 2007 SP1. You have to use Microsoft Forefront Security
for Exchange Server with Service Pack 1 Beta 2 (FSES SP1 Beta 2). You can download it here.

Note: I was told by Microsoft, "Exchange SP1 Beta 2 requires FSES SP1 Beta 2 (installed before you install the Exchange Service Pack 1 Beta 2)."

So, without further ado, here are my upgrade notes:

  • Took snapshots of DC and EX01 VMs

  • Make a backup of host/Edge server


  • Install ForeFront SP1 Beta 2

  • Follow to disable ForeFront before installing Exchange 2007 SP1

  • Restart and stop all Exchange services, except ADAM

  • Install. Be patient. Configuring common transport polices took 10 minutes by itself.

  • Install completed successfully

  • Re-enabled Forefront as per KB929080, above

  • Restarted the server, checked event logs, tested email inbound/outbound successfully


  • Begin installation

  • Installation failed about halfway through

  • Tried to run again, but got the error, "This installation is forbidden by system policy." Solved using the Local Security Settings tip from Tim Chad at the bottom of this page

  • Restarted installation, but got the error, "The Exchange files are not installed, but the backup settings registry key is present. Only build to build upgrade mode is available."

  • Ran /mode:upgrade from the command line to perform an unattended upgrade setup

  • Got the following output:

Welcome to Microsoft Exchange Server 2007 Unattended Setup

Preparing Exchange Setup

The following server roles will be upgraded
Hub Transport Role
Client Access Role
Mailbox Role

Performing Microsoft Exchange Server Prerequisite Check

Hub Transport Role Checks ......................... FAILED
Setup cannot continue with upgrade because 'C:\Program Files\Microsoft\Exchange Server\bin\ExchHelp.chm' is open. Close the file and restart setup.

Client Access Role Checks ......................... FAILED
Unable to read data from the Metabase. Ensure that Microsoft Internet Information Services is installed.

The World Wide Web (W3SVC) service is either disabled or not installed on this computer. You must exit Setup, install the required component, then restart the Setup process.

Setup cannot continue with upgrade because 'C:\Program Files\Microsoft\Exchange Server\bin\ExchHelp.chm' is open. Close the file and restart setup.

Mailbox Role Checks ......................... FAILED
Unable to read data from the Metabase. Ensure that Microsoft Internet Information Services is installed.

The World Wide Web (W3SVC) service is either disabled or not installed on this computer. You must exit Setup, install the required component, then restart the Setup process.

Setup cannot continue with upgrade because 'C:\Program
Files\Microsoft\Exchange Server\bin\ExchHelp.chm' is open. Close the file and restart setup.

The Exchange Server setup operation did not complete.
Visit and enter the Error ID to find more

Exchange Server setup encountered an error.

  • Set the World Wide Web Publishing Service, IIS Admin Service, and HTTP SSL service to automatic and started (they were disabled)

  • Copy file ExchHelp.chm from \setup\serverroles\common of the setup media into the \Program Files\Microsoft\Exchange Server\Bin directory

  • Re-run /mode:upgrade

  • Success! Restart all servers. Test OWA and Outlook inbound/outbound successfully

Good luck with your own upgrade. Now to test the new SP1 features!

Read more ...

Can't connect to connect to multi-homed server using RDP

Tuesday, October 2, 2007

The problem: You are trying to connect to a server using the Remote Desktop Connection client (RDP) and you get the following error:

Remote Desktop Disconnected
The client could not connect to the remote computer.

Remote connections might not be enabled or the computer might be too busy to accept new connections. It is also possible that network problems are preventing your connection.

Please try connecting again later. If the problem continues to occur, contact your administrator.

If you are using the new Remote Desktop Connection 6.0 Client, the error you get is:

Remote Desktop Disconnected
This computer can't connect to the remote computer.

Try connecting again. If the problem continues, contact the owner of the remote computer or your network administrator.

You checked that Remote Desktop is enabled and you have rights to connect, but it fails every time. What the #$% is going on???
Well, you may have a binding problem with the RDP-Tcp connector. This typically happens with servers with two or more NICs (as is usual with an ISA server). To fix the problem follow these steps:
  1. Logon to the server locally

  2. Click Start, Run, type "tscc.msc /s" (without quotation marks) and click OK

  3. In the Terminal Services Configuration snap-in double-click Connections, then RDP-Tcp in the right pane

  4. Click the Network Adapter tab, select the correct network adapter and click OK

  5. Make sure that you can establish an RDP connection to the server
The change takes effect immediately. No need for a restart.

Read more ...

How to Disable Terminal Service Logins

Monday, October 1, 2007

If you’re ever working on a terminal server, you know that it can be annoying to have users login and disturb whatever you’re doing. Luckily, there’s a quick and easy way to stop them from logging in. Use the "change logon" command.

The syntax is:

change logon {/query /enable /disable}

To disable logons:

change logon /disable

Now when clients attempt to login, they will get the message “Remote logins are currently disabled”. And you can work in peace.

To enable logons:

change logon /enable

To check logon status:

change logon /query

If you find that you’ve disabled logons and you can’t get back in, you can login to the console (mstsc.exe /console) and change the setting. The restriction doesn’t affect console logins. Also, if the server reboots, the setting reverts back to being enabled.

Thanks to Chris Amaris for the tip!

Read more ...