How to identify two different MACI64 computers

조회 수: 11 (최근 30일)
Andy Daubenspeck
Andy Daubenspeck 2022년 8월 15일
댓글: Andy Daubenspeck 2022년 8월 16일
I use an iMac desktop and a Powerbook Pro for program development with a VPN connection to my university. They have slightly different data structures and I would like to be able to identify which one I am using by examining the output from name=computertype as I used to in earlier versions of Matlab. Now both computers return 'MACI64'. getenv is not useful as it returns the address of the current VPN connection. Is there a way to determine when I am using each computer? This is of great help in setting data and results paths.
Thanks,
Andy
  댓글 수: 2
Rik
Rik 2022년 8월 16일
You need to identify something that is different between the two. You could check the existence of some specific folder structure, perhaps?
Walter Roberson
Walter Roberson 2022년 8월 16일
hostname ? Amount of memory?
... I think checking for the two data structure directories is probably the most robust.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2022년 8월 16일
편집: Jan 2022년 8월 16일
You can create a corresponding preference on each computer:
setpref('Computer', 'ID', 'Computer1');
% and on the other machine:
setpref('Computer', 'ID', 'Computer2');
Afterwards this distinguishes the machines:
if strcmp(getpref('Computer', 'ID'), 'Computer1')
...
else
...
end
Not matching your problem, because this concerns Windows only:
For an automatic detection without manual definition before under Windows:
% UUID of the machine:
[status, msg] = system(['powershell -Command ', ...
'"(Get-CimInstance -Class Win32_ComputerSystemProduct).UUID"']);
if status == 0 && ~isempty(msg)
HostUUID = msg(~isspace(msg));
else
fprintf(2, '### %s: %s\n', mfilename, 'Cannot obtain UUID.');
HostUUID = '$noUUID';
end
% DeviceID:
try
msg = winqueryreg('HKEY_LOCAL_MACHINE', ...
'Software\Microsoft\SQMClient', 'MachineID');
catch
msg = '$noKey';
end
DeviceID = strrep(strrep(msg, '{', ''), '}', '');
end
Under Windows also:
R = com.sun.security.auth.module.NTSystem;
DomainSID = get(R, 'DomainSID'); % or: R.getDomainSID
UserSID = get(R, 'UserSID'); % or: R.getUserSID
  댓글 수: 1
Andy Daubenspeck
Andy Daubenspeck 2022년 8월 16일
Thanks very much for this neat solution!
Very appreciated,
Andy

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by