News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Challenge: Run as Administrator

Started by aw27, March 14, 2019, 01:27:55 AM

Previous topic - Next topic

aw27

Without Manifest, without changing compatibility settings, without right clicking and select Run as Administrator or similar ways, how to run my program as Administrator?

Anyone?

TimoVJL

May the source be with you

felipe

this challenge sounds a little against some of the forum rules :shock:


Siekmanski

OpenSCManager in combo with ShellExecute ?
Creative coders use backward thinking techniques as a strategy.

jj2007

include \masm32\include\masm32rt.inc

.code
start:
  .if rv(ShellExecute, 0, chr$("runas"), rv(GetCommandLine), 0, 0, 0)>32
inkey "hi admin"
  .endif
  exit
end start

aw27

Very good JJ!
Only the guy that says "hi admin" is not the administrator.  :(

Vortex

Hello,

Maybe this one :

CreateProcessWithLogonW :

https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-createprocesswithlogonw

jj2007

Quote from: AW on March 14, 2019, 05:13:09 AM
Only the guy that says "hi admin" is not the administrator.  :(

Yep, you are right :P

include \masm32\include\masm32rt.inc

.code
start:
  invoke GetCommandLine
  xchg eax, ebx
  .if sdword ptr find$(1, ebx, "-A")>0
MsgBox 0, "I am the admin, really", "Hi", MB_OK
  .else
invoke ShellExecute, 0, chr$("runas"), ebx, chr$("-A"), 0, 0
  .endif
  exit
end start