Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Would like some assistance on how to obtain the Windows product id from the registry that will work where the WIndows (Windows 2003 Server, 2008 Server) is on a Domain or Workgroup and a remote machine.

E.g. I am on a workstation on a domain and I want a pure c# (if possible) solution to obtaining the product id of a specific Windows 2008 machine on the network (it is actually the machine running a SQL Server instance).

Sorry for the confusion , I hope I have extended the question enough as to explain the situation clearer.

share|improve this question

migrated from Jan 11 '10 at 17:39

This question came from our site for professional and enthusiast programmers.

Look at the Magical Jellybean Keyfinder

The Magical Jelly Bean Keyfinder is a freeware open source utility that retrieves your Product Key (cd key) used to install Windows from your registry. It allows you to print or save your keys for safekeeping. It works on Windows 95, 98, ME, 2000, XP, Vista, 7, Server 2003, Server 2008, Office XP, Office 2003, and Office 2007 family of products

share|improve this answer
I require the product id (i think..) but thank you for this neat tool. I have updated the question to reflect the change. – Coolcoder Jan 8 '10 at 10:36

Try to use

EXEC xp_instance_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductId'

share|improve this answer

The product key is not kept in the registry. The product ID (which is partly based on the product key) is available in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

share|improve this answer
I mean the product id, I have updated the question. – Coolcoder Jan 8 '10 at 10:35
up vote 0 down vote accepted

I did a bit of thinking outside of the box and I have come up with slightly different solution, just need to test it out. I think I can get the product id from the machine via the SQL instance...

DECLARE @retvalue int, @data varchar(500)
EXECUTE @retvalue = master.dbo.xp_instance_regread 'HKEY_LOCAL_MACHINE',
'SOFTWARE\Microsoft\Windows NT\CurrentVersion',
'ProductId', @param = @data OUTPUT
PRINT 'ProductId: '+ @data

I will update this if this solution works , however if anyone has another solution please let me know.

share|improve this answer
This looks like a winner; it returns the correct value and works in all versions of SQL (through to 2008). Would probably need wrapping up to ensure it works on specific OSs (in case registry location changes?) but other than that it looks good. – Coolcoder Jan 8 '10 at 10:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .