4,391 Posts served
10,712 Conversations started
- Academic

- Android

- Art, Music, & Animation

- Embedded Computing

- Events

- Game Development

- Graphics & Media

- Intel SW Partner Program

- Intel® AppUp Developer Program

- Manageability & Security

- Mobility

- Open Source

- Parallel Programming

- Performance and Optimization

- Power Efficiency

- Site News & Announcements

- Software Tools

- Association for Computing Machinery TechNews (ACM)
- Go Parallel! (Dr. Dobbs)
- HPCwire (Tabor Communications, Inc.)
- insideHPC (John West)
- Joe Duffy's Weblog (Microsoft)
- Microsoft Parallel Programming Development Center (Microsoft Germany)
- MultiCoreInfo.com
- scalability.org (Scalable Informatics)
- Software Dev Blog (Intel Germany)
- Soft Talk Blog (Intel United Kingdom)
- The Moth (Microsoft)
Playing around with Windows Home Server
By Ylian Saint-hilaire (Intel) (246 posts) on December 15, 2009 at 12:33 am
I have been playing around with Microsoft Windows Home Server (WHS). Very nice devices that backup your home computers and do all sorts of interesting things. Of course, the fact they you can add more functionality to them is very important. I have long toyed around with the idea of writing an Intel AMT add-in for WHS. If we had such an add-in, I would not need to install any management software on any of my computers, I would just install in on the home server and use that when I need it. Also, since the home server is built for outside-in access, it would be possible to control my home computers from outside the home. With Intel AMT, I get even more control. Lastly, we could probably use IDE-R to boot the recovery CD when needed. No need to look for the CD if you got more than one computer on the network.
So I wrote my first add-in. All is well, you then create an installer (.msi) file that you can use to install the add-in on the WHS device. But here is something special. You need to set a special variable "WHSLogo = 1" in the .MSI file otherwise, WHS will not recognize this MSI as being an add-in and will ignore it. MSDN offers different ways of creating the MSI file, but I wanted to use what was built-into Visual Studio 2008. Well, I wrote myself some code that does it. The following will find my .MSI file, open it and add the "WHSLogo = 1" if needed. I compile this and put it into my post build script and I get quick and easy WHS compatible MSI installer.
Enjoy!
Ylian
static void SetupWHSLogo()
{
// Find the installer
FileInfo f = new FileInfo("../../../../Addin.msi");
if (!f.Exists) { MessageBox.Show("Installer Not Found. Current = " + Application.StartupPath); return; }
MessageBox.Show("Installer at: " + f.FullName);
// Open the MSI installer
Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer");
WindowsInstaller.Installer installer = (WindowsInstaller.Installer)Activator.CreateInstance(type);
WindowsInstaller.Database db = installer.OpenDatabase(f.FullName, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeTransact);
// Search for the WHSLogo property
bool whslogofound = false;
WindowsInstaller.View v2 = db.OpenView("SELECT * FROM Property");
v2.Execute(null);
WindowsInstaller.Record record = v2.Fetch();
while (record != null)
{
string str1 = record.get_StringData(1);
string str2 = record.get_StringData(2);
if (str1 == "WHSLogo") whslogofound = true;
record = v2.Fetch();
}
// If we can't find it, add it.
if (whslogofound == false)
{
WindowsInstaller.View v = db.OpenView("INSERT INTO Property (Property.Property, Property.Value) VALUES ('WHSLogo', '1')");
v.Execute(null);
db.Commit();
MessageBox.Show("Added: WHSLogo = 1");
}
}
Categories: Software Tools
Tags: Home Server, WHS, WHSLogo
For more complete information about compiler optimizations, see our Optimization Notice.
Comments (4)
| December 17, 2009 12:23 AM PST
Andreas M. | Nice article! You could also use a script from the Windows Installer SDK to set the WHSLogo property in a post build (no need for custom code). See Brendan Grant's blog post: http://ihatelinux.blogspot.com/2007/08/setting-whslogo-from-comma nd-line.html |
| December 17, 2009 7:57 AM PST
Al West |
Hi, I converted your project to a Console App which takes an MSI as a parameter. Thanks for the initial code: using System; using System.Collections.Generic; using System.Text; using System.IO; namespace MakeWHSMSI { class Program { static void Main(string[] args) { if (args.Length > 0 ) if (!string.IsNullOrEmpty(args[1])) { FileInfo fileInfo = new FileInfo(args[1]); Console.WriteLine("MakeWHSmsi: Parameter Passed : [0}", args[1]); SetupWHSLogo(fileInfo); return; } Console.WriteLine("MakeWHSmsi: No Parameter Passed"); SetupWHSLogo(); } static void SetupWHSLogo() { FileInfo f = new FileInfo("../../../../Addin.msi"); SetupWHSLogo(f); } static void SetupWHSLogo(FileInfo f) { // Find the installer if (!f.Exists) { Console.WriteLine("Installer Not Found. Current = " + f.DirectoryName); return; } Console.WriteLine("Installer at: " + f.FullName); // Open the MSI installer Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer"); WindowsInstaller.Installer installer = (WindowsInstaller.Installer)Activator.CreateInstance(type); WindowsInstaller.Database db = installer.OpenDatabase(f.FullName, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeTransact) ; // Search for the WHSLogo property bool whslogofound = false; WindowsInstaller.View v2 = db.OpenView("SELECT * FROM Property"); v2.Execute(null); WindowsInstaller.Record record = v2.Fetch(); while (record != null) { string str1 = record.get_StringData(1); string str2 = record.get_StringData(2); if (str1 == "WHSLogo") whslogofound = true; record = v2.Fetch(); } // If we can't find it, add it. if (whslogofound == false) { WindowsInstaller.View v = db.OpenView("INSERT INTO Property (Property.Property, Property.Value) VALUES ('WHSLogo', '1')"); v.Execute(null); db.Commit(); Console.WriteLine("Added: WHSLogo = 1"); } } } } |
| December 17, 2009 4:21 PM PST
Ylian Saint-hilaire (Intel)
| Yes, I saw the VB script but I wanted to use C# all the way. I also built myself a small hosting application what would run the control without the need to install it into a WHS device. Nice for development. Then I added this method into the hosting app so it would both run the control but also with a command line change the MSI. Finaly I added the command line into my installer post-build script. Makes everything nice and easy. |
Trackbacks (4)
- Add-In Source Code for Intel AMT « MS Windows Home Server
December 16, 2009 2:48 AM PST - Add-In Source Code für Intel AMT : Home Server Blog
December 16, 2009 7:39 AM PST - Intel Software Network Blogs » Just got my HP MediaSmart Server LX195
December 17, 2009 4:40 PM PST - Just got my HP MediaSmart Server LX195
December 17, 2009 9:20 PM PST



Lar