Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Jan 11 '10 at 17:39

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

add comment

4 Answers

Look at the Magical Jellybean Keyfinder http://www.magicaljellybean.com/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
add comment

Try to use

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

share|improve this answer
add comment

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
add comment
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.