Why does the SYSTEM command not find an existing Windows registry key in MATLAB (R2011b)?
2 次查看(过去 30 天)
显示 更早的评论
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').
采纳的回答
MathWorks Support Team
2013-6-16
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!