Why does the SYSTEM command not find an existing Windows registry key in MATLAB (R2011b)?

3 visualizaciones (últimos 30 días)
I am trying to query some Windows registry keys through MATLAB. However, on some machines, when I run the following command:
>> [status, CV] = system('REG QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v "ProductId"')
I get the following error:
status =
1
CV =
The system was unable to find the specified registry key or value.
This error is still thrown even when I am logged in as an administrator. However, when I query the same registry key ("ProductId") through the DOS command line:
C:> REG QUERY HKLM\Software\Microsoft\Windows” “NT\CurrentVersion /v ProductId
I have no issues. I can also see the key in the registry (through 'regedit').

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 16 de Jun. de 2013
Since we are unable to reproduce the issue on our end, we suggest the following:
1. If "ProductId" is available in your registry, the MATLAB command WINQUERYREG will return it. For example, on my machine:
>> winqueryreg('HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductID')
ans =
00392-918-5000002-85980
Make sure there is a space between Windows and NT.
2. If (1) fails, you can try the following .NET code in MATLAB to check the registry entries:
>> NET.addAssembly('mscorlib');
>> root = Microsoft.Win32.Registry.LocalMachine;
>> root.OpenSubKey('SOFTWARE\Microsoft\Windows
NT\CurrentVersion').GetValue('ProductId')
ans =
00392-918-5000002-85980
3. If neither works, try the same code from a VB app or a C# app on the problem machine.
4. If that still does not work, the issue is with the machine setup, and your best bet would be to contact your system administrator or Microsoft.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2011b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by