How to obtain the Windows product id from registry from a remote machine
Solution 1
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.
Solution 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
Solution 3
Try to use
EXEC xp_instance_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductId'
Related videos on Youtube
Coolcoder
Updated on September 17, 2022Comments
-
Coolcoder over 1 year
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.
-
Admin over 14 yearsI mean the product id, I have updated the question.
-
swordfish over 14 yearsThis 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.