Skip to content

Commit 877a17a

Browse files
committed
dotnet is_admin: faster for unix
1 parent 2bc6e17 commit 877a17a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

+stdlib/+dotnet/is_admin.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
function y = is_admin()
44

5+
6+
y = logical.empty;
7+
if ~ispc()
8+
return
9+
end
10+
511
% Use .NET System.Security.Principal to check for admin privileges
612
try
713
identity = System.Security.Principal.WindowsIdentity.GetCurrent();
814
principal = System.Security.Principal.WindowsPrincipal(identity);
915
y = principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator);
1016
catch e
1117
dotnetException(e)
12-
y = logical.empty;
1318
end
1419

1520
end

0 commit comments

Comments
 (0)