Author Topic: Challenge: Run as Administrator  (Read 3331 times)

aw27

  • Guest
Challenge: Run as Administrator
« on: March 14, 2019, 01:27:55 AM »
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

  • Member
  • *****
  • Posts: 1318
Re: Challenge: Run as Administrator
« Reply #1 on: March 14, 2019, 02:02:16 AM »
my_setup.exe my_install.exe  ;)
May the source be with you

felipe

  • Member
  • *****
  • Posts: 1381
Re: Challenge: Run as Administrator
« Reply #2 on: March 14, 2019, 02:16:56 AM »
this challenge sounds a little against some of the forum rules :shock:

aw27

  • Guest
Re: Challenge: Run as Administrator
« Reply #3 on: March 14, 2019, 02:28:28 AM »
Only teasing...

Siekmanski

  • Member
  • *****
  • Posts: 2718
Re: Challenge: Run as Administrator
« Reply #4 on: March 14, 2019, 02:59:19 AM »
OpenSCManager in combo with ShellExecute ?
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 13944
  • Assembly is fun ;-)
    • MasmBasic
Re: Challenge: Run as Administrator
« Reply #5 on: March 14, 2019, 05:11:30 AM »
Code: [Select]
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

  • Guest
Re: Challenge: Run as Administrator
« Reply #6 on: March 14, 2019, 05:13:09 AM »
Very good JJ!
Only the guy that says "hi admin" is not the administrator.  :(

Vortex

  • Member
  • *****
  • Posts: 2788
Re: Challenge: Run as Administrator
« Reply #7 on: March 14, 2019, 06:27:55 AM »

jj2007

  • Member
  • *****
  • Posts: 13944
  • Assembly is fun ;-)
    • MasmBasic
Re: Challenge: Run as Administrator
« Reply #8 on: March 14, 2019, 08:33:44 AM »
Only the guy that says "hi admin" is not the administrator.  :(

Yep, you are right :P

Code: [Select]
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