Why does the SYSTEM command not find an existing Windows registry key in MATLAB (R2011b)?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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').
Akzeptierte Antwort
MathWorks Support Team
am 16 Jun. 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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!