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

2 visualizzazioni (ultimi 30 giorni)
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').

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 16 Giu 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.

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2011b

Community Treasure Hunt

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

Start Hunting!

Translated by