0

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.

4 Answers 4

2

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

1
  • 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, 2010 at 10:36
2

Try to use

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

0

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

1
  • I mean the product id, I have updated the question.
    – Coolcoder
    Jan 8, 2010 at 10:35
0

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.

1
  • 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, 2010 at 10:41

You must log in to answer this question.

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