Author Topic: A question on "run as administrator"  (Read 743 times)

clamicun

  • Member
  • **
  • Posts: 240
A question on "run as administrator"
« on: August 17, 2016, 08:53:26 PM »
A question on "run as administrator"

My program writes in "C:\Program Files"   and "C:\Windows\System32".
This only works, if it is run as administrator, otherwise it writes into "C:\Users\Mic_User\AppData\Local\VirtualStore\Program Files".

I would like to create a Messagebox giving a warning, if the program isn't run as administrator.
I could try to write "something" and if it fails give out the MessageBox.

Is there a possibility to know directly after start, how it is run ? 

jj2007

  • Member
  • *****
  • Posts: 7548
  • Assembler is fun ;-)
    • MasmBasic

clamicun

  • Member
  • **
  • Posts: 240
Re: A question on "run as administrator"
« Reply #2 on: August 18, 2016, 11:50:19 PM »
Last question...

INVOKE IsUserAnAdmin
Returns TRUE or FALSE

What's wrong with that function ?
So the whole check on the user is only one line.

jj2007

  • Member
  • *****
  • Posts: 7548
  • Assembler is fun ;-)
    • MasmBasic
Re: A question on "run as administrator"
« Reply #3 on: September 14, 2016, 12:05:08 AM »
@Donnewany author: Your bot sucks. Invest a bit more time in parsing the forum messages, and creating more intelligent replies.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4811
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: A question on "run as administrator"
« Reply #4 on: September 14, 2016, 08:51:14 AM »
Donnewany has been promoted to another web site.  :P
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

sinsi

  • Member
  • ****
  • Posts: 996
Re: A question on "run as administrator"
« Reply #5 on: September 14, 2016, 10:02:34 AM »
Last question...

INVOKE IsUserAnAdmin
Returns TRUE or FALSE

What's wrong with that function ?
So the whole check on the user is only one line.

Quote from: MSDN
IsUserAnAdmin is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.
Requirements

Minimum supported client
Windows XP [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
End of client support
Windows Vista

End of server support
Windows Server 2008

You could add a manifest specifying requireAdministrator.
I can walk on water but stagger on beer.