Archive: How do I check for Administrator?


I need to make sure that the person logged in has administrator access because of other third party drivers I need to install. I only care about this for WinNT/2K/XP. For Win95/98/ME, it can install without checking. How would I go about checking that? Is there some sort of registry setting I can check?

Thanks,
Aarif


hi,

there is no registry setting you can check as that is handled by advapi32.dll; so that is (AFAIK) not yet possible with nsis.

cu yzo


Yes, this sounds like an option which should be added to NSIS. Speaking of NSIS, where's justin?
I guess he's busy on WA3. :o


hi,

maybe someone could implement this into nsis:



// Returns True if logged on as admin
// always Returns True on Win9x

type
HNDL = THandle;

function OpenSCManager(lpMachineName, lpDatabaseName:
PChar; dwDesiredAccess: DWORD): HNDL; stdcall;
external 'advapi32.dll' name 'OpenSCManagerA';

function CloseServiceHandle(hSCObject: HNDL): BOOL;
stdcall; external 'advapi32.dll' name
'CloseServiceHandle';

function IsAdminLoggedOn: Boolean;
var
hndlSC: HNDL;
begin
if Win32Platform <> VER_PLATFORM_WIN32_NT then
Result := True
else
begin
hndlSC := OpenSCManager(nil, nil, GENERIC_READ or GENERIC_WRITE or
GENERIC_EXECUTE);
Result := hndlSC <> 0;
if Result then CloseServiceHandle(hndlSC)
end
end;


my c knowledge is not that good to do that

cu yzo

Thanks yazno.

I have modified the source code (probably about 10 lines of code) to implement a new command "IfAdmin" using the code supplied by yazno. The command works like "IfErrors". If anyone is interrested in the changes, let me know, and I will post them here.

Thanks again to yazno.

Aarif


hi,

that is cool, maybe you could send the source/changes to justin, so we could all take advantage of it :)

cu yzo


How do I send the changes to Justin?

Aarif


hi

just send it to justin@nullsoft.com

cu yzo