The MASM Forum

General => The Workshop => Topic started by: clamicun on August 17, 2016, 08:53:26 PM

Title: A question on "run as administrator"
Post by: clamicun 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 ? 
Title: Re: A question on "run as administrator"
Post by: jj2007 on August 17, 2016, 09:49:09 PM
http://masm32.com/board/index.php?topic=763.msg6649#msg6649
Title: Re: A question on "run as administrator"
Post by: clamicun 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.
Title: Re: A question on "run as administrator"
Post by: jj2007 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.
Title: Re: A question on "run as administrator"
Post by: hutch-- on September 14, 2016, 08:51:14 AM
Donnewany has been promoted to another web site.  :P
Title: Re: A question on "run as administrator"
Post by: sinsi on September 14, 2016, 10:02:34 AM
Quote from: clamicun 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.

Quote from: MSDNIsUserAnAdmin 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.