Fernando Machado Píriz's Blog

Posts about enterprise architecture and related topics

Developing SharePoint 2010 solutions in your laptop using Windows Server 2008 R2 with Hyper-V

with 4 comments

If you usually develop SharePoint Server 2010 solutions from your office desktop, it is very likely that you have a full sized server there, with all required servers and tools installed on it, or better yet if you use different server versions or configurations, you have multiple virtual machines, each one with all required software installed on it. In such case, this blog post is not for you.

If your scenario is different, as mine is, and you work from different places using a laptop, and need to have different SharePoint Server 2010 installations (different versions, different languages, etc.), then you need your servers and tools running on virtual machines.

With Microsoft Office SharePoint Server 2007, both your host and your guest operating systems could be 32 bits, since you were able to use the 32 bits version of SharePoint servers. In addition, it was possible to use a client (non-server) operating system as host, by using Microsoft Virtual PC 2007 for example. With SharePoint Server 2010 that is not true anymore and the guest operating system needs to be a 64 bits one, let us say Windows Server 2008 R2 64 bits. This is because SharePoint Server 2010 only runs on top of 64 bits operating system.

You cannot have any 64 bits operating system on a virtual machine by using Microsoft Virtual PC 2007 or the new Windows 7’s Windows Virtual PC; the only way you can virtualize a 64 bits operating system is by using a hypervisor: Windows Server 2008 with the Hyper-V role.

Does it look a bit odd to run a hypervisor on a laptop, does not? Well, probably you are right, but you will get accustomed to it, believe me.

What do you lose by using Windows Server 2008 with Hyper-V as the host operating system of your laptop? If you use the default installation, you do not have:

  • Audio and Windows Media Player. The Windows Audio service is disabled by default and the Windows Media Player is not installed in a server. Usually there is nobody listening music at the servers room, it is a very noisy environment.
  • Wi-Fi connectivity. The Wireless LAN Service feature is not installed. Usually servers a wired-connected to the network.
  • Aero. The Themes service is disabled by default to preserve server’s resources.
  • Search. The Windows Search service is disabled by default also to preserve server’s resources.
  • Sleep and hibernate. Usually servers are always on and never sleep or hibernate, even turn off.
  • Event Tracker. You cannot shut down the system without explaining the reason why first.
  • Internet Explorer’s Enhanced Security. Every time you try to visit a website you get a message saying why you should not browse the web from a server.

But what is reasonable in a server, is not reasonable in the laptop you use for your everyday work, right? You want to hear music, you need wireless connections, you need to search for files and email messages, you love the look and feel of Aero, and you do not carry your laptop with the hard disk drive spinning every time you move from one place to another.

Except for sleeping and hibernating, you can have audio, wireless connectivity, file and email search, and a desktop look and feel in Windows Server 2008 R2. Unfortunately, as soon as you add the Hyper‑V role, you lose the ability to sleep/hibernate your laptop. But news are no so bad, you will be able to sleep/hibernate your laptop by temporarily disabling the hypervisor without removing it.

In this blog post I will show you how to tweak a default Windows Server 2008 R2 installation so it looks and behaves like a Windows 7 desktop. This is how mine looks:

WS2008R2

Enabling audio

This one is easy. Simply click the Start button and type “services” in the search box and then open the Services console. Look for the Windows Audio service, right click and choose Properties, then in the Properties dialog box change the Start type from Disabled to Automatic.

Or open an administrative Command Prompt and type sc \\[machine] config audiosrv start= auto replacing [machine] for your computer’s name and then type net start audiosrv.

Enabling Wi-Fi, Aero and Search

Install the missing features. Click the Start button and type “server” in the search box and then open the Server Manager console. On the left panel click on Features, then click on the Add Features link on the right panel. In the Add Features Wizard select and install the features Desktop Experience and Wireless LAN Service.

Once these features are installed, open the Services console again and look for the Themes service, right click and choose Properties, then in the Properties dialog box change the Start type from Disabled to Automatic. Do the same with the Desktop Window Manager Session Manager service. Do the same also with the Windows Search service but set Start type to Automatic (Delayed start).

Or open an administrative Command Prompt and type for %%s in (uxsms themes) do (sc \\[machine] config %%s start= auto) and then sc \\[machine] config wsearch start= auto and finally for %%s in (uxsms themes wsearch) do (net start %%s).

Enabling sleep/hibernate

Let us assume you have installed Windows Server 2008 R2 and then you added the Hyper-V role. If you open an administrative Command Prompt and then you run the bcdedit /enum {current} you will get an output like this one:

clip_image003

bcdedit is not a “binary coded decimal” editor, as you might probably guess, but a “boot configuration datastore” editor. Note the hypervisorlaunchtype set to Auto in the last line. Also note the Windows Server 2008 R2 description; this is the text you see during boot when multiple boot configurations are available or during system recovery.

Copy this boot configuration to a new one by typing bcdedit /copy {current} /d “Microsoft Windows Server 2008 R2 (w/o Hyper-V)” in an administrative Command Prompt. The text between the quotes is the description of the new boot configuration. You can choose a description different than mine.

The command outputs a message including a GUID of the new boot configuration. Disable the hypervisor role in the new boot configuration by using bcdedit /set {GUID} hypervisorlaunchtype off where GUID is the GUID shown by the previous command.

You are done. Additionally, if you want to change your default boot configuration, or change the time to display the list of configurations during boot, you can use bcdedit or the Startup and Recovery dialog box in the System Properties.

This new boot configuration will disable Hyper-V and let you enable sleep/hibernation, but (obviously) you will need to reboot your laptop before that. This is by far more efficient than completely removing the Hyper-V role, which by the way, also requires a reboot.

To enable hibernation after reboot, you will need to open an administrative Command Prompt and run powercfg –H (uppercase haitch).

Disabling Event Tracking

Open the Local Group Policy Editor by clicking on Start and typing “edit policy” in the search box. Then expand Local Computer Policy in the left pane, then Computer Configuration, then Administrative Templates, finally System. In the right pane look for Display Shutdown Event Tracker, double click it to edit its configuration, and choose Disable.

Disabling Internet Explorer Enhanced Security

Click the Start button and then type “server” in the search box and then open the Server Manager console. Select the root node in the left tree and then click on the Configure IE ESC link in the right pane. Choose Off to disable the setting.

Final remarks

Now you can use your laptop in two scenarios: as a hypervisor or as a regular laptop. In the first scenario, is highly recommended that you disable back services like Windows Audio, Themes, Windows Search, etc. and turn Aero themes off, in order to preserve system resources. In addition, if you have other servers like SQL Server or even a SharePoint server installed on top of your host operating system, it is highly recommended to turn them off while using the hypervisor.

Since you need to shut down the system before moving your laptop while using the hypervisor, and since you need to reboot to switch from one scenario to the other, consider buying a solid state disk drive for your system partition to speed up shut down and start up times. By the way, with a disk like that, turning your laptop off and on could be even faster than hibernating and restoring from a regular hard disk drive, if your laptop has a lot of RAM, as it should have to use eventually multiple virtual machines simultaneously.

To facilitate switching from the hypervisor scenario to the regular laptop scenario, you can use the following batch files and scripts.

Use this batch file to enable or disable search by simply typing search on or search off in an administrative Command Prompt. This batch file not only stops or starts the search service; it also enables or disables it, so the current status is kept after rebooting.

@echo off

rem Enables and starts or stops and disables search services

rem Search services:
rem	Windows Search

set x=%1%#
if %x%==# goto usage
if %1%==on goto enable
if %1%==off goto disable

:usage

echo "Usage: search on|off"
goto end

:enable

rem Enables desktop services

for %%s in (wsearch) do (sc \\[machine] config %%s start= delayed-auto)
for %%s in (wsearch) do (net start %%s)

pause
goto end

:disable

rem Disables search services

for %%s in (wsearch) do (net stop %%s)
for %%s in (wsearch) do (sc \\[machine] config %%s start= disabled)

pause
goto end

:end

 

You can use this other batch file to enable or disable the audio related services, by typing audio on or audio off in an administrative Command Prompt.

@echo off

rem Enables and starts or stops and disables audio related services

rem Audio services:
rem	Windows Audio
rem	Windows Audio Endpoint Builder

set x=%1%#
if %x%==# goto usage
if %1%==on goto enable
if %1%==off goto disable

:usage

echo "Usage: audio on|off"
goto end

:enable

rem Enables audio services

for %%s in (audiosrv audioendpointbuilder) do (sc \\[machine] config %%s start= auto)
for %%s in (audiosrv audioendpointbuilder) do (net start %%s)

pause
goto end

:disable

rem Disables audio services

for %%s in (audiosrv audioendpointbuilder) do (net stop %%s)
for %%s in (audiosrv audioendpointbuilder) do (sc \\[machine] config %%s start= disabled)

pause
goto end

:end

 

To stop all servers’ services, there is another batch file you can use to stop and disable or start and enable these services, by typing servermode off or server mode on on an administrative Command Prompt.

@echo off

rem Enables and starts or stops and disables server related services

rem Server services:
rem	Application Host Helper Service
rem	Distributed Transaction Coordinator
rem	Simple Mail Transfer Protocol (SMTP)
rem	IIS Admin Service
rem	Net.Msmq Listener Adapter (depends on Message Queuing)
rem	Message Queuing
rem	SharePoint 2010 Timer
rem	SharePoint 2010 Tracing
rem	SharePoint 2010 User Code Host
rem	SharePoint Foundation Search V4
rem	SharePoint Server Search 14
rem	SQL Full-text Filter Daemon Launcher (MSSQLSERVER)
rem	SQL Server Agent (MSSQLSERVER) (depends on SQL Server (MSSQLSERVER))
rem	SQL Server (MSSQLSERVER)
rem	SQL Server (SHAREPOINT)
rem	SQL Server (SQLEXPRESS)
rem	SQL Server Analysis Services (MSSQLSERVER)
rem	SQL Server Browser
rem	SQL Server Integration Services 10.0
rem	SQL Server Reporting Services (MSSQLSERVER)
rem	SQL Server VSS Writer
rem	Visual Studio Team Foundation Background Job Agent
rem	Visual Studio Team Foundation Build Service Host
rem	World Wide Web Publishing Service

set x=%1%#
if %x%==# goto usage
if %1%==off goto disable
if %1%==on goto enable

:usage

echo "Usage: servermode on|off"
goto end

:disable

rem Disables server services

for %%s in (apphostsvc SMTPSVC msdtc iisadmin NetMsmqActivator msmq sptimerv4 sptracev4 spusercodev4 spsearch4 osearch14 SQLSERVERAGENT MSSQLSERVER MSSQL$SHAREPOINT MSSQL$SQLEXPRESS MSSQLServerOLAPService SQLBrowser MsDtsServer100 ReportServer SQLWriter TFSJobAgent TFSBuildServiceHost W3SVC) do (net stop %%s)
for %%s in (apphostsvc msdtc SMTPSVC iisadmin NetMsmqActivator msmq sptimerv4 sptracev4 spusercodev4 spsearch4 osearch14 MSSQLFDLauncher SQLSERVERAGENT MSSQLSERVER MSSQL$SHAREPOINT MSSQL$SQLEXPRESS MSSQLServerOLAPService SQLBrowser MsDtsServer100 ReportServer SQLWriter TFSJobAgent TFSBuildServiceHost W3SVC) do (sc \\[machine] config %%s start= disabled)

pause
goto end

:enable

rem Enables server services

for %%s in (apphostsvc msdtc iisadmin NetMsmqActivator msmq sptimerv4 sptracev4 spusercodev4 MSSQLFDLauncher SQLSERVERAGENT MSSQLSERVER MSSQL$SHAREPOINT MSSQL$SQLEXPRESS MSSQLServerOLAPService SQLBrowser MsDtsServer100 ReportServer SQLWriter TFSJobAgent TFSBuildServiceHost W3SVC) do (sc \\[machine] config %%s start= auto)
for %%s in (msdtc) do (sc \\[machine] config %%s start= delayed-auto)
for %%s in (spsearch4 osearch14 MSSQLFDLauncher SMTPSVC) do (sc \\[machine] config %%s start= demand)
for %%s in (apphostsvc msdtc iisadmin NetMsmqActivator msmq sptimerv4 sptracev4 spusercodev4 spsearch4 osearch14 MSSQLFDLauncher SQLSERVERAGENT MSSQLSERVER MSSQL$SHAREPOINT MSSQL$SQLEXPRESS MSSQLServerOLAPService SQLBrowser MsDtsServer100 ReportServer SQLWriter TFSJobAgent TFSBuildServiceHost W3SVC SMTPSVC) do (net start %%s)

pause
goto end

:end

 

Since hypervisor’s services are needed only when you boot using the hypervisor configuration, these services are enabled or disabled on a separate batch file.

@echo off

rem Starts or stops Hyper-V related services

if %1%==off goto disable
if %1%==on goto enable
goto end

:disable

for %%s in (vhdsvc nvspwmi vmms hvboot) do (net stop %%s)
for %%s in (vhdsvc nvspwmi vmms hvboot) do (sc \\[machine] config %%s start= disabled)
pause
goto end

:enable

for %%s in (vhdsvc nvspwmi vmms) do (sc \\[machine] config %%s start= auto)
for %%s in (hvboot) do (sc \\[machine] config %%s start= demand)
for %%s in (vhdsvc nvspwmi vmms hvboot) do (net start %%s)
pause
goto end

:end

 

Since I do a lot of work with many different servers (SQL Server, SharePoint Server, Team Foundation Server, etc.), the list of services I have in this batch file is big. You can remove or add your own services from the batch file. If you plan to modify it, pay attention to the following:

1. Dependencies. You need to stop a services after all the services that depends on it, to avoid confirmation messages stopping your batch file processing. Make sure your start them in the reverse order.

2. Start type. Disabling services is easy: there is just one disabled status. But enabling them is a bit more complicated, because there is more than one start type: automatic, automatic but delayed, and manual. Make sure you return the start type to the original one.

The extra mile: if you want your Windows Server 2008 R2 installation to look exactly (well, very similar at least) than a Windows 7 desktop, with Aero and themes, you can use these additional batch files and scripts. You bet it, there are desktopmode on and desktopmode off commands to do this.

@echo off

rem Enables and starts or stops and disables desktop related services

rem Desktop services:
rem	Windows Audio
rem	Windows Audio Endpoint Builder
rem	Windows Search
rem	Desktop Window Manager Session Manager
rem	Disk Defragmenter (stop only)
rem	Themes

set x=%1%#
if %x%==# goto usage
if %1%==on goto enable
if %1%==off goto disable

:usage

echo "Usage: desktopmode on|off"
goto end

:enable

rem Enables desktop services

for %%s in (audiosrv audioendpointbuilder uxsms defragsvc themes) do (sc \\[machine] config %%s start= auto)
for %%s in (wsearch) do (sc \\[machine] config %%s start= delayed-auto)
for %%s in (defragsvc) do (sc \\[machine] config %%s start= demand)
for %%s in (audiosrv audioendpointbuilder wsearch uxsms themes) do (net start %%s)
DesktopTheme.vbs

pause
goto end

:disable

rem Disables desktop services

for %%s in (audiosrv audioendpointbuilder wsearch uxsms defragsvc themes) do (net stop %%s)
for %%s in (audiosrv audioendpointbuilder wsearch uxsms defragsvc themes) do (sc \\[machine] config %%s start= disabled)
ServerTheme.vbs

pause
goto end

:end

 

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""C:\Windows\Resources\Themes\aero.theme"""

Wscript.Sleep 15000
WshShell.AppActivate("Desktop Properties")
WshShell.Sendkeys "%FC"
WshShell.Sendkeys "{F4}"

 

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""C:\Windows\Resources\Ease of Access Themes\classic.theme"""

Wscript.Sleep 1000
WshShell.AppActivate("Desktop Properties")
WshShell.Sendkeys "%FC"
WshShell.Sendkeys "{F4}"

 

One final recommendation: add the folder where this batch files and scripts are stored to the PATH environment variable.

Have fun.

PS: In order to be completely honest, there are other things you will lose if you choose to install Windows Server 2008 R2 in your laptop. First, the Bluetooth drivers are usually not available for server operating systems, so be aware if you depend on Bluetooth devices for your daily work. Second, depending on your system’s hardware, other device drivers might not be available for server operating systems. The most common ones are the fingerprint reader and the smart card reader drivers. You can try installing the drivers for Windows 7, but this may or may not work. Finally, some third party tools detect a non-desktop operating system and refuse to run or even to install. So far, I can live with all these limitations, but you cannot say I did not tell you.

About these ads

Written by fernandomachadopiriz

February 12, 2011 at 12:13 pm

4 Responses

Subscribe to comments with RSS.

  1. [...] This post was mentioned on Twitter by Fabian Imaz, Fabian Imaz. Fabian Imaz said: Great article to develop solutios in #SharePoint, http://wp.me/pSSy1-38, by @fmachadopiriz [...]

    • Thanks for your post Fernando. Its very helpful. I’m not a dev person I just want to deploy a SP 2010 and prepare for MCTS and MCTP exams for SP 2010 but I don’t have dedicated server(s) for that only way is on my 4 Gigs laptop with Server 2008 so i will try it on it :)

      Ivan

      June 9, 2012 at 11:47 am

  2. [...] a previous post I wrote about how to configure your laptop to act alternatively as a virtualization server or as a [...]

  3. [...] Developing SharePoint 2010 solutions in your laptop using Windows Server 2008 R2 with Hyper-V « Fe… [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 223 other followers

%d bloggers like this: