Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Studio Installation and Setup.
  • Page:
  • 1

TOPIC:

Administrator Privileges mode calculation broken 12 years 2 months ago #2520

  • Dann Corbit
  • Dann Corbit's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
I tried running from a command prompt with administrator priv and also from a shortcut given administrator priv. Hence, something is broken here:
AT > NUL
IF %ERRORLEVEL% EQU 0 (
GOTO GO_execute
) ELSE (
ECHO.
ECHO ERROR: "User has NOT Administrator Privileges"
ECHO Please, run this script with Administrator Privileges
ECHO Installation Aborted...
ECHO.
Pause
GOTO GO_END
)

Please Log in or Create an account to join the conversation.

Administrator Privileges mode calculation broken 12 years 2 months ago #2521

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Please, more info Sir
your OS etc..
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Administrator Privileges mode calculation broken 12 years 1 month ago #2584

  • tt
  • tt's Avatar
  • Visitor
  • Visitor
windows xp sp3
кроме проблем с определением привелегий, там еще проблемы с созданием ярлыков, и отсутствием directx11.
Но все они обходятся простым комментированием лишних строк в bat файлах. И ручным созданием нужных ярлыков.

Please Log in or Create an account to join the conversation.

Administrator Privileges mode calculation broken 12 years 1 month ago #2585

  • tt
  • tt's Avatar
  • Visitor
  • Visitor
Если у вас точно есть права администратора, а магическая проверка говорит что их нет, то проверьте а запущена ли у вас служба schedule?
Вообще проверять права пользователя с помощью планировщика заданий это жесть.

Please Log in or Create an account to join the conversation.

Administrator Privileges mode calculation broken 12 years 1 month ago #2595

  • 4aiman
  • 4aiman's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Comix creator
  • Posts: 227
  • Thank you received: 12
English, please. Besides, xp sp3 is perfectly supported and if you have some troubles installing it - try installing smth different from Zver or Hobbit or Looner where those things are disabled...

And if you have some other way to check whether user is admin or not from bat file - do commit ;)
PS: like this: stackoverflow.com/questions/4051883/batc...eck-for-admin-rights
コンソールマニアック

Please Log in or Create an account to join the conversation.

Administrator Privileges mode calculation broken 12 years 1 month ago #2603

  • tt
  • tt's Avatar
  • Visitor
  • Visitor
I can read in English, but the writing is very bad.
I have the original windows, but unnecessary and safe services are disabled.
You can check whether the user is the administrator creating the desired utility. You're a developer and console maniac ;)

Here, for example, like this
program IsAdmin;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, SysUtils, Windows, CustApp

type

  { TCheckIsAdmin }

  TCheckIsAdmin = class(TCustomApplication)
  protected
    function IsAdmin: Boolean;
    procedure DoRun; override;
  public
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
  end;

{ TCheckIsAdmin }

function TCheckIsAdmin.IsAdmin: Boolean;
const
  SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5));
  SECURITY_BUILTIN_DOMAIN_RID = $00000020;
  SE_GROUP_ENABLED            = $00000004;
  SE_GROUP_USE_FOR_DENY_ONLY  = $00000010;
  DOMAIN_ALIAS_RID_ADMINS     = $00000220;
var
  Sid: PSID;
  CheckTokenMembership: function(TokenHandle: THandle; SidToCheck: PSID; var IsMember: BOOL): BOOL; stdcall;
  IsMember: BOOL;
  Token: THandle;
  GroupInfoSize: DWORD;
  GroupInfo: PTokenGroups;
  I: Integer;
begin
  Result := False;

  if Win32Platform <> VER_PLATFORM_WIN32_NT then // Windows 9x/Me
  begin
    Result:=True;
    Exit;
  end;

  if not AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, Sid) then
    Exit;

  try
    CheckTokenMembership:=nil;
    if Lo(GetVersion) >= 5 then
      Pointer(CheckTokenMembership):=GetProcAddress(GetModuleHandle(advapi32), 'CheckTokenMembership');

    if Assigned(CheckTokenMembership) then
    begin
      if CheckTokenMembership(0, Sid, IsMember) then
        Result:=IsMember;
    end
    else
    begin
      GroupInfo := nil;
      if not OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, Token ) then
      begin
        if GetLastError <> ERROR_NO_TOKEN then
          Exit;
        if not OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, Token) then
          Exit;
      end;

      try
        GroupInfoSize := 0;
        if not GetTokenInformation(Token, TokenGroups, nil, 0, GroupInfoSize) and
           (GetLastError <> ERROR_INSUFFICIENT_BUFFER) then
          Exit;

        GetMem(GroupInfo, GroupInfoSize);
        if not GetTokenInformation(Token, TokenGroups, GroupInfo, GroupInfoSize, GroupInfoSize) then
          Exit;

        for I := 0 to GroupInfo^.GroupCount-1 do
         if EqualSid(Sid, GroupInfo^.Groups[I].Sid) and
            (GroupInfo^.Groups[I].Attributes and (SE_GROUP_ENABLED or SE_GROUP_USE_FOR_DENY_ONLY) = SE_GROUP_ENABLED) then
         begin
           Result:=True;
           Break;
         end;
      finally
        FreeMem(GroupInfo);
        CloseHandle(Token);
      end;
    end;
  finally
    FreeSid(Sid);
  end;
end;

procedure TCheckIsAdmin.DoRun;
begin
  if IsAdmin then
  begin
   WriteLn('Admin');
   ExitProcess(0);
  end
  else
  begin
   WriteLn('User');
   ExitProcess(1);
  end;
end;

constructor TCheckIsAdmin.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
end;

destructor TCheckIsAdmin.Destroy;
begin
  inherited Destroy;
end;

var
  Application: TCheckIsAdmin;
begin
  Application:=TCheckIsAdmin.Create(nil);
  Application.Title:='CheckIsAdmin';
  Application.Run;
  Application.Free;
end.

Please Log in or Create an account to join the conversation.

Administrator Privileges mode calculation broken 12 years 1 month ago #2608

  • 4aiman
  • 4aiman's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Comix creator
  • Posts: 227
  • Thank you received: 12
I've wrote a whole bunch of text here, but forum said that my session expired...
So:
1. I think we must use shell scripts since we can't make one cross-platform utility that will launch under any OS and will be the size of a shell script. And even if that woud be 2 or 3 (win, lin, mac), then it would be nice to see a full installer of CT (which someday will come to existance to joy us, although I'm fine with shell scripts ;) )

2. Offtop. Please, Sternas (or some other guy, who's responsible for the forum), please, increase the amount of time before forum thinks that user left. Or make it configurable... Please, I haven't enough fingers on my hands to count how many times I ended up with my message lost...
コンソールマニアック

Please Log in or Create an account to join the conversation.

Administrator Privileges mode calculation broken 12 years 1 month ago #2609

  • administrator
  • administrator's Avatar
  • Visitor
  • Visitor
I increase forum edit time to 1200 second (from 600 sec)

Please Log in or Create an account to join the conversation.

Administrator Privileges mode calculation broken 12 years 1 month ago #2639

  • 4aiman
  • 4aiman's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Comix creator
  • Posts: 227
  • Thank you received: 12
Thanks!

And now about the privileges :)
I know, that one can "google it out", but here's the link to the page that would explain what one should do if he/she gets 1717 error while trying to launch sheluder service. It'll be usefull for those who launched installation under "administrator", but get a message about insufficient rights.
コンソールマニアック

Please Log in or Create an account to join the conversation.

  • Page:
  • 1